dashboardModule.directive("dashboardApptWorkBlock", ["$log", "$timeout", "$q", "$modal", "$rootScope", "$injector", "apptUtil", "permissionProvider", "appNav", "officeOptionSvc", "aresNotification", "loginContext", "localCache", "aresDialog", "aresModalShelf", "moduleOptionProvider", "followupUtil", "enums", "patientSvc", "moduleUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/block/dashboard-appt-work-block.html", controller: "DashboardApptWorkCtrl", scope: { titleClass: "@" }, link: function(n, r) { var it = null,
                tt = null,
                ft = a.getCache(a.keys.DoctorDashboardApptWorkSortFields),
                nt = ft.loadObject(),
                ut = null,
                at = function() { var t, i;
                    ii();
                    t = this;
                    e.formatApptGrid(this, function(n, i) { var u = t.dataItem(i),
                            f;
                        u && (f = r.find(i).find("td.appointment-status-td"), f.attr("id", "apptState" + u.id)) });
                    i = this.items();
                    $(i).each(function() { var n = $(this).find(".row-number");
                        $(n).html($(this).index() + 1) });
                    n.refreshedTime = Ares.timestamp() },
                vt = function(n, t) { if (nt = n.dataSource.sort(), t && (nt = t), nt && nt.length > 0) { ft.saveObject(nt); var i = _.find(nt, { field: "startTimeStr" });
                        i || (nt.push({ field: "startTimeStr", dir: "asc" }), n.dataSource.sort(nt)) } else t || ft.saveObject([]) },
                rt = function(t, i) { i == "charge" ? s.goToCharge(t.patientId) : i == "emr" ? s.goToEMR(t.patientId) : i == "followup" ? k.getPatientHead(t.patientId).then(function(i) { var r = { pid: t.patientId, appointId: t.id, creatorId: l.userId, followupRule: { ruleType: b.FollowupRuleType.ManualRule, creationMode: b.FollowupCreationMode.AllAtOnce, timeMode: b.FollowupTimeMode.Absolute }, appts: [] };
                        w.openEditFollowupDialog(r, i).then(function() { n.refreshApptWork() }) }) : i == "revisit" && n.scheduleAppointment(t.patientId) },
                d = function(n, t) { return t[n.field] ? "btn-success" : "" },
                g = function(n, t) { return t[n.field] ? "glyphicon glyphicon-ok" : "fa fa-plus" },
                yt = function() { l.dashboardType == "Consultant" ? n.commands = { consultSeatAppt: { text: "开始接诊", field: "isConsulting", classNameFunc: d, iconFunc: g, exec: n.consultSeatAppt, canExec: e.canConsultSeatAppt }, setMedicalExam: { text: "创建检查", field: "hasMedicalExam", classNameFunc: d, iconFunc: g, exec: n.setMedicalExam, canExec: e.executeStrictForConsult }, consultAppt: { text: "创建咨询", field: "isConsulted", classNameFunc: d, iconFunc: g, exec: n.consultAppt, canExec: e.canConsultAppt }, checkInAppt: { text: "开始分诊", field: "isCheckedIn", classNameFunc: d, iconFunc: g, exec: n.checkInAppt, canExec: e.canConsultantCheckInAppt }, createFollowUpAppt: { text: "创建新预约", field: "hasRevisit", classNameFunc: d, iconFunc: g, exec: n.createFollowUpAppt, canExec: e.executeStrictForConsult }, goToCharge: { text: "创建收费", field: "hasChargeOrder", classNameFunc: d, iconFunc: g, exec: function(n) { rt(n, "charge") }, canExec: e.executeStrictForConsult }, goToFollowup: { text: "创建新随访", field: "hasFollowup", classNameFunc: d, iconFunc: g, exec: et, canExec: e.executeStrictForConsult }, completeAppt: { text: "治疗结束", field: "isCompleted", classNameFunc: d, iconFunc: g, exec: n.completeAppt, canExec: e.canComplete } } : (n.commands = { seatAppt: { text: "开始接诊", field: "isSeated", classNameFunc: d, iconFunc: g, exec: n.seatAppt, canExec: e.canCall }, setMedicalExam: { text: "创建检查", field: "hasMedicalExam", classNameFunc: d, iconFunc: g, exec: n.setMedicalExam, canExec: e.executeStrict }, transferAppt: { text: "开始转诊", field: "hasTransferred", classNameFunc: d, iconFunc: g, exec: n.transferAppt, canExec: e.canTransfer }, completeAppt: { text: "治疗完成", field: "isCompleted", classNameFunc: d, iconFunc: g, exec: n.completeAppt, canExec: e.canComplete }, goToCharge: { text: "创建收费", field: "hasChargeOrder", classNameFunc: d, iconFunc: g, exec: pt, canExec: e.executeStrict }, goToMedicalRecord: { text: "创建病历", field: "hasMedicalRecord", classNameFunc: d, iconFunc: g, exec: function(n) { rt(n, "emr") }, canExec: e.executeStrict }, goToRevisit: { text: "复诊预约", field: "hasRevisit", classNameFunc: d, iconFunc: g, exec: function(n) { rt(n, "revisit") }, canExec: e.canCreateRevisit }, goToFollowup: { text: "创建新随访", field: "hasFollowup", classNameFunc: d, iconFunc: g, exec: et, canExec: e.executeStrict } }, l.dashboardType == "Doctor" && (n.commands.instrumentsUse = { text: "器械使用", field: "instrumentsUse", classNameFunc: function() { return "" }, iconFunc: function() { return "fa fa-plus" }, exec: ht })) },
                pt = function(n) { rt(n, "charge") },
                si = function(n) { return e.canSeat(n) },
                et = function(n) { if (o.isAllowed("patientFollowup.history"))
                        if (o.isAllowed("patientFollowup.create")) rt(n, "followup");
                        else return c.error("没有创建随访权限"), !1;
                    else return c.error("没有随访权限操作权限"), !1 },
                f = function(t, i, r) { return { title: t, template: function(t) { return t[i] || (t[i] = n.commands[i]), n.isStrict && (t.isStrict = !0), '<ares-command-item command="::dataItem.' + i + '" tag="::dataItem"><\/ares-command-item>' }, width: r || "50px", attributes: { "class": "cell-crowded" } } },
                wt = function() { var t = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientNameCode", title: "姓名", width: "120px", attributes: { "class": "patient-td" }, template: function(n) { return n.patientHead && n.patientHead.tags && n.patientHead.tags.length > 0 && angular.forEach(n.patientHead.tags, function(n) { n.textColor = n.itemValue ? Ares.getForegroundColor(n.itemValue) : Ares.getForegroundColor("#fff") }), '<ares-patient-namecard patient="::dataItem.patientHead" appt="::dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "apptTimeStr", title: "预约/挂号时间", width: "60px" }, { field: "apptStartEndTimeStr", title: "预约时间", width: "150px" }, { field: "apptTypeStr", title: "预约类型", width: "60px" }, { field: "checkInType", title: "就诊类型", width: "60px" }, { field: "doctorName", title: "医生", width: "60px" }, { field: "department", title: "科室", width: "60px" }, { field: "appoinmentProcedureContent", title: "预约项目", attributes: { "class": "cell-left cell-truncate" } }, { field: "notes", title: "&nbsp;&nbsp;备注&nbsp;&nbsp;&nbsp;&nbsp;", attributes: { "class": "cell-left cell-truncate", title: "#:notes#" } }, ],
                        u = { field: "stateStr", title: "就诊状态", width: "70px", sortable: !1, attributes: { "class": "appointment-status-td cell-nowrap" }, template: function(n) { return n.isYibaoCheckIn ? '<span class="enyo-text-primary show-detail" title="当前患者使用医保挂号">' + n.stateStr + ' <span style="background-color:#7ed321;border-radius:3px;padding:0px 2px;color:white;">医<\/span><\/span>' : '<span class="enyo-text-primary show-detail">' + n.stateStr + "<\/span>" } },
                        i, r;
                    t.splice(9, 0, u);
                    l.isAssistant && (i = { field: "doctorName", title: "医生", width: "60px" }, t.splice(2, 0, i));
                    l.dashboardType == "Consultant" && o.isAllowed("patientFollowup.create") && (r = { title: "全选", headerTemplate: "<input name='selectAll' id='selectAll' type='checkbox' />", width: "50px", sortable: !1, headerAttributes: { style: "text-align:center;" }, template: '<input type="checkbox" id="#: id #" patientId="#: patientId #" doctorId="#: doctorId #" startTime="#: startTime #" consultantId="#: consultantId #"/>' }, t.splice(1, 0, r));
                    l.dashboardType == "Consultant" ? (t.push(f("接诊", "consultSeatAppt")), n.openMedicalExam && t.push(f("检查", "setMedicalExam")), t.push(f("咨询", "consultAppt")), t.push(f("分诊", "checkInAppt")), t.push(f("预约", "createFollowUpAppt")), t.push(f("收费", "goToCharge")), t.push(f("随访", "goToFollowup")), t.push(f("治疗结束", "completeAppt"))) : (t.push(f("接诊", "seatAppt")), n.openMedicalExam && t.push(f("检查", "setMedicalExam")), t.push(f("转诊", "transferAppt")), t.push(f("收费", "goToCharge")), t.push(f("病历", "goToMedicalRecord")), t.push(f("预约", "goToRevisit")), t.push(f("随访", "goToFollowup")), t.push(f("治疗完成", "completeAppt")));
                    l.dashboardType === "Doctor" && p.isCssdEnabled() && t.push(f("器械使用", "instrumentsUse"));
                    n.apptGridOption = { columns: t, scrollable: !1, sortable: !0, resizable: !0, selectable: "single", change: function() { it = this.dataItem(this.select()).id }, dataBound: at, model: { id: "id" } } },
                bt = function(t) { tt || (tt = r.find("#apptList").data("kendoGrid"));
                    tt.dataSource.data(n.appts);
                    t ? ot(t) : it && ot(it);
                    r.find("#apptList th").bind("click", function() { vt(tt) }) },
                ot = function(n) { var i = $(r).find("#apptList"),
                        u = i.data("kendoGrid"),
                        e = u.dataSource,
                        f = e.get(n),
                        t;
                    f && (t = i.find("tbody>tr[data-uid=" + f.uid + "]"), t ? (u.select(t), it = n) : it = null) },
                kt = function() { r.find("#daysBeforeTodayInput").change(function() { n.$apply(function() { var i = r.find("#daysBeforeTodayInput").val(),
                                t;
                            i == "自定义" ? (t = Ares.today(), n.dateRange = { startDate: moment(t).toDate(), endDate: moment(t).add(1, "d").toDate() }, n.isShowDate = !0) : (n.isShowDate = !1, n.refreshApptWork()) }) }) },
                dt = function(n) { var t = r.find("#apptState" + n.id);
                    t.effect("pulsate", { times: 2 }) },
                gt = function() { var i = r.find("#daySelectBtn");
                    i.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectBtn").datepicker("hide");
                        n.isInitialized && t(function() { n.date = i.date;
                            n.refreshApptWork() }, 100) });
                    i.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                ni = function() { $("#daySelectBtn").datepicker("update", moment(n.date).format("YYYY-MM-DD")) },
                ti = function() { var t = i.defer(); return h.getOfficeOption(h.optionKeys.IsMedicalExamOpen).then(function(i) { n.openMedicalExam = i ? !0 : !1;
                        t.resolve() }).catch(function() { n.openMedicalExam = !1;
                        t.resolve() }), t.promise },
                ii = function() { r.find("#apptList td input[type='checkbox']").each(function() { var t = this;
                        $(t).on("click", function() { var t = $(this),
                                u = parseInt(t.attr("id")),
                                f = parseInt(t.attr("patientId")),
                                e = t.attr("doctorId"),
                                o = t.attr("startTime"),
                                s = t.attr("consultantId"),
                                i;
                            this.checked ? (_.find(n.selectedAppts, { id: u }) === undefined && n.selectedAppts.push({ id: u, patientId: f, doctorId: e, startTime: o, consultantId: s }), r.find("#apptList td input[type='checkbox']:enabled").length === r.find("#apptList td input[type='checkbox']:checked").length && (i = r.find("#apptList th input[type='checkbox']")[0], i.checked = !0)) : (n.selectedAppts = _.reject(n.selectedAppts, { id: u }), i = r.find("#apptList th input[type='checkbox']")[0], i.checked = !1) }) });
                    r.find("#apptList th input[type='checkbox']").each(function() { var n = this,
                            t; if ($(n).attr("title", "全选"), t = $(n).attr("name"), t === "selectAll") { $(n)[0].checked = !1;
                            $(n).on("click", function() { this.checked ? st(!0) : st(!1) }) } }) },
                st = function(t) { r.find("#apptList td input[type='checkbox']").each(function() { var i = $(this),
                            r = parseInt(i.attr("id")),
                            u = parseInt(i.attr("patientId")),
                            f = i.attr("doctorId"),
                            e = i.attr("startTime"),
                            o = i.attr("consultantId");
                        this.checked = t;
                        this.checked ? _.find(n.selectedAppts, { id: r }) === undefined && n.selectedAppts.push({ id: r, patientId: u, doctorId: f, startTime: e, consultantId: o }) : n.selectedAppts = _.reject(n.selectedAppts, { id: r }) }) },
                ri = function() { var t, i, r; if (n.selectedAppts && n.selectedAppts.length == 0 || !n.selectedAppts) { v.info("创建随访计划", "请选择要创建随访的预约"); return } t = [];
                    angular.forEach(n.selectedAppts, function(n) { t.push({ apptId: n.id, patientId: n.patientId, apptStartTime: n.startTime, apptDoctorId: n.doctorId, apptConsultantId: n.consultantId }) });
                    i = { creatorId: l.userId, followupRule: { ruleType: b.FollowupRuleType.ManualRule, creationMode: b.FollowupCreationMode.AllAtOnce, timeMode: b.FollowupTimeMode.Absolute } };
                    r = w.openBatchCreateFollowupDialog(i, t);
                    r.then(function() { n.refreshApptWork();
                        u.$broadcast("createBatchFollowUp", {});
                        n.selectedAppts = [] }) },
                ht = function(n) { var t = y.open({ template: "<cssd-business-instrument-use-dialog-view><\/cssd-business-instrument-use-dialog-view>", controller: "CssdBusinessInstrumentUseDialogCtrl", title: "器械使用", resolve: { host: function() { return { patientId: n.patientId } } }, needActive: !0 }) },
                hi = function() {},
                ui = function() { var t = i.defer(); return n.getDepartmentData().then(i => { var r = i.departments,
                            u = i.doctorDepartment;
                        r && r.length > 0 && (n.showDepartment = !0, r.unshift({ itemName: "全部科室" }), n.department || n.department == "" || (n.department = u && u.length > 0 && n.includeUnspecified ? u : ""), fi(r), ut && ct());
                        t.resolve() }), t.promise },
                fi = function(t) { ut = r.find("#departments").kendoDropDownList({ placeholder: "请选择科室", dataTextField: "itemName", dataValueField: "itemName", dataSource: t, change: function(t) { var i = t.sender.value();
                            n.department = i == "全部科室" || !n.includeUnspecified ? "" : i;
                            n.refreshApptWork().then(function() { lt() }) } }).data("kendoDropDownList") },
                ct = function() { if (ut) { var t = n.department == "" ? "全部科室" : n.department;
                        ut.value(t) } },
                ei = function() { n.includeUnspecified || (n.department = "", ct());
                    n.refreshApptWork() },
                lt = function() { var t = r.find("#apptList").data("kendoGrid");
                    t.dataSource.data(n.appts) },
                oi = function() { return l.dashboardType != "Consultant" && n.includeUnspecified && n.showDepartment };
            (function() { n.selectedAppts = [];
                n.isInitialized = !1;
                n.isShowDate = !1;
                n.refreshApptGrid = bt;
                n.includeUnspecified = !1;
                n.showDepartment = !1;
                n.date = Ares.today();
                n.playFlashEffect = dt;
                n.createBatchFollowup = ri;
                n.showInstrumentsDialog = ht;
                n.onIncludeUnspecifiedApptsChange = ei;
                n.refreshKendoGrid = lt;
                n.isShowDepartment = oi;
                n.refreshedTime = Ares.timestamp();
                yt();
                ti().then(function() { wt() });
                kt();
                gt();
                n.initSearchCriteria().then(function(t) { return n.criteria = t, ui() }).then(function() { return n.refreshApptWork(n.criteria) }).then(function() { n.isInitialized = !0;
                    tt = r.find("#apptList").data("kendoGrid");
                    tt.dataSource.data(n.appts) });
                n.$watch("date", function() { n.date && ni() }) })() } } }]);
dashboardModule.controller("DashboardApptWorkCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "dashboardSvc", "appointmentConsultSvc", "loginContext", "patientUtil", "apptUtil", "appointmentSvc", "patientSvc", "eventAggregator", "aresNotification", "sessionCache", "officeOptionSvc", "aresDialog", "speechCallSvc", "aresModalShelf", "appNav", "moduleOptionProvider", "dataDicSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt) { "use strict"; var vi = p.getCache(p.keys.DashboardApptWorkSearchCriteria),
        st = u("toApptStateString"),
        ht = u("toDoctorName"),
        ct = u("toAppointmentTypeStr"),
        rt = null;
    w.isStrongStrictAllowed().then(function(n) { t.isStrict = n }); var lt = function(n) { for (var t, i = 0; i < n.length; i++) { if (t = n[i], t.id = t.appointId, t.apptTypeStr = ct(t.appointmentType), t.startTime = t.appointDateTime, t.stateStr = st(t), t.appointDateTime)
                    if (t.endAppointDateTime) { var r = moment(t.appointDateTime),
                            u = moment(t.endAppointDateTime),
                            f = u.diff(r, "minutes");
                        t.apptStartEndTimeStr = r.format("HH:mm") + "-" + u.format("HH:mm") + " " + f + "分钟" } else t.apptStartEndTimeStr = moment(t.appointDateTime).format("HH:mm");
                t.startTimeStr = moment(t.appointDateTime).format("HH:mm");
                t.checkInTimeStr = t.isCheckedIn && t.checkInTime ? moment(t.checkInTime).format("HH:mm") : "";
                t.apptTimeStr = t.checkInTimeStr && t.checkInTimeStr != "" ? t.checkInTimeStr : t.startTimeStr;
                t.isFirstVisitStr = t.isFirstVisit ? "初诊" : "复诊";
                t.doctorName = ht(t.doctorId);
                t.isConsulted = t.hasAppointConsult } s.dashboardType == "Consultant" && (n = _.filter(n, function(n) { return n.stateStr == "未确认" || n.stateStr == "已确认" || n.stateStr == "已挂号" })) },
        yi = function(n, t) { var i = 0,
                r; return n._stateNumber == undefined && (n._stateNumber = ut(n)), t._stateNumber == undefined && (t._stateNumber = ut(t)), i = t._stateNumber - n._stateNumber, i == 0 && (r = n.isCheckedIn ? "checkInTimeStr" : "startTimeStr", n[r] > t[r] ? i = 1 : n[r] < t[r] && (i = -1)), i },
        ut = function(n) { var t = c.getApptStateNumber(n); return c.compareApptState(n, ">=isCompleted") && (t = -t), t },
        at = function(n) { var i = _.clone(n);
            i.id = n.appointId;
            i.doctorId = s.providerId;
            c.transferAppt(i).then(function() { y.success("转诊成功");
                t.refreshApptWork() }) },
        vt = function(n) { l.consultTriageLog(n).success(function() {}); var i = s.dashboardType == "Consultant";
            yt(n, i).then(function() { c.checkInApptById(n.id, i).then(function(n) { var r = { patientId: n.patientId, consultantId: s.providerId, appointmentId: n.id };
                    i ? (y.success("分诊成功"), t.refreshApptWork()) : a.updatePatientConsultant(r).success(function() { y.success("分诊成功");
                        t.refreshApptWork() }) }) }) },
        yt = function(n, r) { var u = i.defer(); return r ? l.getAppointment(n.id).success(function(n) { n.isStrict = t.isStrict; var i = c.canConsultantCheckInAppt(n);
                i ? u.resolve(i) : (y.error("该患者已经被接诊"), u.reject(i)) }) : u.resolve(!0), u.promise },
        pt = function(n) { var n = { patientId: n.patientId, isFirstVisit: !1, action: "add", officeId: s.officeId, consultantId: s.consultantId };
            h.createFollowUpAppt(n).then(function() { y.success("预约成功");
                t.refreshApptWork() }) },
        wt = function(n) { var i, u;
            n.patient || (n.patient = { name: n.patientName });
            i = t.openSpeechCall;
            i ? (u = r.open({ animation: !0, backdrop: "static", template: "<speech-call-view><\/speech-call-view>", controller: "SpeechCallCtrl", size: "lg", resolve: { apptHost: function() { return { patientId: n.patientId, isFirstVisit: !0, apptData: n } } } }), u.result.then(function(i) { ni(n).then(function(r) { var u, f;
                    t.isSpeechCallScreenEnabled ? (f = { speechCallMode: i.speechCallMode, apptId: r.id, operatoryId: i.operatoryId, room: i.room, checkInNo: r.checkInNo, doctorName: i.doctorName, patientName: i.patient.name, roomNo: i.roomNo }, k.speechCallPatient(f).success(function() { y.success("接诊成功") }).error(function() { y.error("叫号失败") })) : (u = "请，" + n.patient.name + "，到，" + i.room + "，就诊。", u = encodeURI(u), u = encodeURI(u), k.speechCall(u).success(function() { y.success("接诊成功") }).error(function() { y.error("叫号失败") }));
                    t.refreshApptWork() }) })) : c.seatAppt(n).then(function() { y.success("接诊成功");
                t.refreshApptWork() }) },
        bt = function(n) { w.getOfficeOption(w.optionKeys.IsNewMedicalExamEnabled).then(function(t) { t && t == !0 ? kt(n) : dt(n) }) },
        kt = function(n) { g.goToPatient(n.patientId, "medical-exam-patient", null) },
        dt = function(n) { var i = r.open({ animation: !0, backdrop: "static", template: "<patient-doctor-medical-exam-view><\/patient-doctor-medical-exam-view>", controller: "PatientDoctorMedicalExamCtrl", size: "md", resolve: { apptHost: function() { return { apptData: n } } } });
            i.result.then(function() { t.refreshApptWork() }) },
        gt = function() { w.getOfficeOption(w.optionKeys.IsOpenSpeechCall).then(function(n) { t.openSpeechCall = n ? !0 : !1 }) },
        ni = function(n) { var t = i.defer(),
                r = s.dashboardType == "Doctor",
                u = null; return u = r ? "接诊患者【" + n.patient.name + "】？" : "患者【" + n.patient.name + "】已经开始治疗？", l.seatAppointment(n.id).success(function(n) { t.resolve(n) }).error(function(n) { n.name == "SeatAppointmentException" && y.error("患者已经被接诊");
                t.reject() }), t.promise },
        ti = function(n) { n.patient || (n.patient = { name: n.patientName });
            c.consultSeatAppt(n).then(function() { y.success("接诊成功");
                t.refreshApptWork() }) },
        ii = function(n) { n.patient || (n.patient = { name: n.patientName });
            c.consultApptById(n.id).then(function() { it() }) },
        ri = function(n) { n.patient || (n.patient = { name: n.patientName });
            c.completeAppt(n).then(function() { t.refreshApptWork() }) },
        ui = function(n) { a.getPatientConsultantId(n).then(function(t) { h.createFollowUpApptByPatientId(n, null, null, t.data).then(function() { it() }) }) },
        ft = function(n) { var r = i.defer(),
                u = angular.copy(n); console.log(u);return e.getApptWork(u).then(function(n) { t.appts = n.data;
                t.appts && t.appts.length > 0 ? et(t.appts).then(function() { r.resolve() }) : r.resolve() }), r.promise },
        it = function(n) { var f = i.defer(),
                r, u, o;
                return t.dateRange = si(), r = moment(t.dateRange.start).format("YYYY-MM-DD"), u = moment(t.dateRange.end).format("YYYY-MM-DD"), _.isEmpty(n) ? (r = moment(t.dateRange.start).format("YYYY-MM-DD"), u = moment(t.dateRange.end).format("YYYY-MM-DD")) : (r = moment(t.startDate).format("YYYY-MM-DD"), u = moment(t.endDate).format("YYYY-MM-DD")), o = { doctorId:s.doctorId,includeUnspecified: t.includeUnspecified, includeCanceled: t.includeCanceled, startDate: r, date: r, endDate: u, includeLeft: t.includeLeft, includeUnCheckIn: t.includeUnCheckIn, includeCheckedOut: t.includeCheckedOut, department: t.department, currentDay: t.currentDay }, hi(o), t.criteria = angular.copy(o), s.dashboardType == "Consultant" ? e.getConsultantApptWork(r, u, s.providerId, t.department).then(function(n) { return t.appts = n.data, t.selectedAppts = [], et(t.appts) }).then(function() { t.refreshKendoGrid();
                f.resolve() }) : ft(t.criteria).then(function() { t.selectedAppts = [];
                t.refreshKendoGrid();
                f.resolve() }), f.promise },
        et = function(n) { var r = i.defer(); return h.formatPatientHeadInfo(n).then(function(n) { n ? (lt(n), s.dashboardType != "Consultant", t.appts = n, r.resolve()) : (t.appts = [], r.resolve()) }), r.promise },
        fi = function() { v.subscribe(t, v.events.AppointmentCreated, ot);
            v.subscribe(t, v.events.AppointmentUpdated, ot) },
        ot = function(n, i) { oi(i) ? (it(), (i._apptAction == "CheckIn" || i._apptAction == "CheckOut") && f(function() { t.playFlashEffect(i) }, 300)) : f(function() { c.removeApptFromApptList(i, t.appts);
                s.dashboardType != "Consultant" && t.refreshApptGrid() }) },
        ei = function(n, i) { i = i || "d"; var r = moment(t.date).add(n, i).toDate();
            t.date = r;
            rt && f.cancel(rt);
            rt = f(function() { it().then(function() { t.refreshApptGrid() }) }, 100) },
        oi = function(n) { var i = !1,
                r; return n.isPending || n.doctorId != s.doctorId && (s.dashboardType != "Doctor" || n.department != s.department) && (s.dashboardType != "Consultant" || n.consultantId != s.consultantId) || (r = moment(n.startTime).toDate(), i = t.dateRange.contains(r)), i },
        si = function() { var n = t.date || Ares.today(),
                i = moment(n).toDate(),
                r = moment(n).add(1, "d").toDate(); return new Ares.DateRange(i, r) },
        hi = function(n) { if (n != null) { var t = JSON.stringify(n);
                localStorage.setItem("doctorDashboardQueryCriteria", t) } },
        ci = function() { var f = i.defer(),
                n = {},
                u = localStorage.getItem("doctorDashboardQueryCriteria"),
                r; return u && u.length > 0 && (n = JSON.parse(u)), _.isEmpty(n) || (n.date && (t.date = n.date), n.includeCanceled && (t.includeCanceled = n.includeCanceled), n.includeUnspecified && (t.includeUnspecified = n.includeUnspecified), n.includeLeft && (t.includeLeft = n.includeLeft), (n.includeUnCheckIn || n.includeUnCheckIn == !1) && (t.includeUnCheckIn = n.includeUnCheckIn), (n.includeCheckedOut || n.includeCheckedOut == !1) && (t.includeCheckedOut = n.includeCheckedOut), n.startDate && (t.startDate = n.startDate), n.endDate && (t.endDate = n.endDate), n.department && (t.department = n.department), n.currentDay && (t.currentDay = n.currentDay)), r = moment(Ares.today()), t.currentDay && t.currentDay === r.format("YYYY-MM-DD") || (t.currentDay = r.format("YYYY-MM-DD"), t.startDate = r.format("YYYY-MM-DD"), t.endDate = r.add(1, "d").format("YYYY-MM-DD"), t.date = t.startDate, n && (n.date = t.date)), f.resolve(n), f.promise },
        pi = function(n) { var t; return (t = n.isCheckedIn && n.appointmentTime && n.appointmentTime.checkInTime ? moment(n.appointmentTime.checkInTime) : moment(n.startTime), t.format("YYYY-MM-DD") == moment(n.recordCreatedTime).format("YYYY-MM-DD")) ? "到" : t > moment(n.recordCreatedTime) ? "约" : void 0 },
        li = function() { var n = i.defer(); return w.getOfficeOption(w.optionKeys.IsSpeechCallScreenEnabled).then(function(i) { t.isSpeechCallScreenEnabled = i;
                n.resolve(!0) }), n.promise },
        ai = function() { var n = i.defer(),
                t = tt.departmentDic.load(),
                r = tt.allProviderDic.load(); return i.all([t, r]).then(t => { var r = t[0],
                    u = t[1],
                    i = _.find(u, n => n.id == s.doctorId),
                    f = i ? i.department : "";
                n.resolve({ departments: r, doctorDepartment: f }) }), n.promise };
    (function() { t.initSearchCriteria = ci;
        t.consultAppt = ii;
        t.transferAppt = at;
        t.seatAppt = wt;
        t.completeAppt = ri;
        t.scheduleAppointment = ui;
        t.refreshApptWork = it;
        t.checkInAppt = vt;
        t.createFollowUpAppt = pt;
        t.navigate = ei;
        t.isInitialize = !0;
        t.includeCanceled = !1;
        t.includeUnspecified = !1;
        t.includeLeft = !1;
        t.includeUnCheckIn = !0;
        t.includeCheckedOut = !0;
        t.showFilter = s.dashboardType == "Doctor" ? !0 : !1;
        t.showCreateBatchButton = s.dashboardType == "Consultant" ? !0 : !1;
        t.department = "";
        t.consultSeatAppt = ti;
        t.setMedicalExam = bt;
        t.getDepartmentData = ai;
        t.queryApptWork = ft;
        fi();
        gt();
        li() })() }]);
dashboardModule.directive("dashboardBlockPanel", ["$log", "loginContext", function(n, t) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/block/dashboard-block-panel.html", scope: { blockTitle: "@", blocks: "=", isProtectedMode: "@", configFunc: "=" }, link: function(n) { var i = t.dashboardType;
            n.isShowSetButton = i != "WebPhoneConsultant" && i != "Doctor" } } }]);
var DashboardBlock = function(n, t, i, r, u, f, e) { this.type = n;
    this.configName = t;
    this.icon = i;
    this.showOrder = r;
    this.isSensitive = u || !1;
    this.onClick = f;
    this.color = e || null };
dashboardModule.directive("dashboardBlockView", ["$log", "$timeout", function(n, t) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/block/dashboard-block-view.html", scope: { block: "=", isProtectedMode: "=" }, link: function(n, i) { var r = function() { n.isProtected = !1 },
                u = function() { n.isProtected = !0 },
                f = function() { var n = i.find(".countup"),
                        t = n.data("to") || 0; if (!(t <= 0)) { var r = n.data("from") || 0,
                            u = n.data("duration") || 2,
                            f = n.data("decimals") || 0,
                            e = { useEasing: !0, useGrouping: !0, separator: ",", prefix: n.data("prefix") || "", suffix: n.data("suffix") || "" },
                            o = new countUp(n[0], r, t, f, u, e);
                        o.start() } };
            (function() { n.showValue = r;
                n.hideValue = u;
                n.isProtected = !0;
                n.$watch("isProtectedMode", function() { n.isProtected = !(n.isProtectedMode == "false") });
                t(f, 100) })() } } }]);
dashboardModule.directive("dashboardFollowupWorkBlock", ["$q", "$timeout", "$window", "apptUtil", "patientSvc", "followupUtil", "loginContext", "officeOptionSvc", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/block/dashboard-followup-work-block.html", controller: "DashboardFollowupWorkCtrl", scope: { titleClass: "@" }, link: function(r, s) { var c = Ares.kendoGridUtil(i, r),
                l = function() { var n = [{ field: "patientNameCode", title: "姓名", width: "120px", attributes: { "class": "patient-td" }, template: function() { return '<ares-patient-namecard patient="::dataItem.patientHead" appt="::dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "privateId", title: "病历号", width: "100px" }, { field: "doctorName", title: "随访医生", width: "100px" }, { field: "otherProviderName", title: "随访人员", width: "100px" }, { field: "visitContent", title: "随访内容", width: "150px" }, { field: "visitResult", title: "随访结果", width: "150px" }, { field: "visitDateTime", title: "计划时间", width: "110px" }, { field: "executeTime", title: "随访时间", width: "120px" }, { field: "status", title: "随访状态", width: "100px" }, { template: c.commandTemplate, title: "", width: "210px" }],
                        t;
                    r.isEnableConsultantDiagnose && n.splice(6, 0, { field: "consultantName", title: "咨询师", width: "60px" });
                    e.isAssistant && (t = { field: "doctorIdStr", title: "医生", width: "60px" }, n.splice(6, 0, t));
                    r.followupGridOption = { columns: n, dataBound: function() { var n = this;
                            $(s).find("#followupList table tbody tr").each(function(t, i) { var r = n.dataItem(i);
                                r.status != "待计划" && s.find(i).find("td .btn-group").find('button[data-action="execute"]').remove();
                                r.status == "已取消" && s.find(i).find("td .btn-group").find('button[data-action="edit"]').remove() }) }, scrollable: !1, sortable: !0, resizable: !0, selectable: "single", model: { id: "id" }, dataSource: { transport: { read: function(n) { r.pageIndex = n.data.page || 1;
                                    r.pageSize = n.data.pageSize || 10;
                                    r.queryFollowupWork().then(function() { n.success(r.pageData) }) } }, pageSize: 10, serverPaging: !0, schema: { data: "items", total: "totalCount" } }, pageable: !0 } },
                a = function() { var n = s.find("#followUpDaySelectBtn");
                    n.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(n) { $("#followUpDaySelectBtn").datepicker("hide");
                        r.isInitialized && t(function() { r.date = n.date;
                            r.queryFollowupWork() }, 100) });
                    n.datepicker("setDate", moment(r.date).format(r.dateFormat)) },
                v = function() { $("#daySelectBtn").datepicker("update", moment(r.date).format("YYYY-MM-DD")) },
                y = function() { o.getOfficeOption(o.optionKeys.EnableConsultantDiagnose).then(function(n) { r.isEnableConsultantDiagnose = n;
                        l();
                        a() }) },
                p = [{ text: "执行", action: "execute" }, { text: "编辑", action: "edit" }, { text: "日志", action: "changeLog" }, ],
                w = function(n) { return _.find(r.followups, function(t) { return t.id == n }) },
                h = function(t, i) { var r = n.defer(); return n.all([u.getFollowup(t), u.getPatientsHeadInfo([i])]).then(function(n) { var t = n[0].data,
                            i = n[1].data[0];
                        r.resolve([t, i]) }), r.promise },
                b = function(n) { h(n.followupId, n.patientId).then(function(n) { f.openEditFollowupDialog(n[0], n[1]).then(function(n) { n && r.initSearchCriteria().then(function() { r.queryFollowupWork() }) }) }) },
                k = function(n) { h(n.followupId, n.patientId).then(function(n) { f.openExecuteFollowupDialog(n[0], n[1]).then(function(n) { n && r.initSearchCriteria().then(function() { r.queryFollowupWork() }) }) }) },
                d = function(n, t, i) { r.$apply(function() { var n = w(i); switch (t) {
                            case "execute":
                                k(n); break;
                            case "edit":
                                b(n); break;
                            case "changeLog":
                                r.showFollowupAuditLog(n.followupId) } }) },
                g = function() { var n = s.find("#followupList").data("kendoGrid");
                    n && n.dataSource.success(r.pageData) };
            (function() { r.isInitialized = !1;
                r.commands = p;
                r.onCommandClick = d;
                r.refreshDate = v;
                r.refreshFollowupGrid = g;
                r.$on("createBatchFollowUp", function() { r.queryFollowupWork() });
                y();
                r.initSearchCriteria().then(function() { r.queryFollowupWork();
                    r.isInitialized = !0 }) })() } } }]);
dashboardModule.controller("DashboardFollowupWorkCtrl", ["$log", "$scope", "$q", "dashboardSvc", "$timeout", "$modal", "loginContext", "patientUtil", "formatUtil", "sessionCache", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var l = h.getCache(h.keys.DashboardFollowupWorkSearchCriteria),
        c = null,
        a = function() { var n = i.defer(),
                u = moment(t.date).format("YYYY-MM-DD"),
                f = moment(t.date).add(1, "d").format("YYYY-MM-DD"),
                h = { startDate: u }; return v(h), r.getFollowupWork("-1", u, f, e.doctorId, e.providerId, t.pageIndex, t.pageSize).success(function(i) { var r = i.items;
                o.formatPatientHeadInfo(r).then(function() { s.formatList(r, { visitDateTime: "date", doctorId: "doctorName" });
                    angular.forEach(r, function(n) { n.id = n.followupId;
                        n.visitDateTime = moment(n.visitDateTime).format("YYYY-MM-DD");
                        n.executeTime && (n.executeTime = moment(n.executeTime).format("YYYY-MM-DD")) });
                    t.followups = r;
                    t.pageData = i;
                    t.refreshFollowupGrid();
                    n.resolve() }) }), n.promise },
        v = function(n) { n != null && l.saveObject(n) },
        y = function(n, i) { i = i || "d"; var r = moment(t.date).add(n, i).toDate();
            t.date = r;
            c && u.cancel(c);
            c = u(function() { a() }, 100) },
        p = function() { var r = i.defer(),
                n = l.loadObject(); return n && n.startDate && (t.date = n.startDate), r.resolve(), r.promise },
        w = function(n) { var t = f.open({ animation: !0, backdrop: "static", template: "<operation-log-list-view><\/operation-log-list-view>", controller: "OperationLogListCtrl", size: "lg", windowClass: "operation-log-dialog", resolve: { host: function() { return { id: n, type: "Followup" } } } }) };
    (function() { t.date = Ares.today();
        t.initSearchCriteria = p;
        t.showFollowupAuditLog = w;
        t.queryFollowupWork = a;
        t.navigate = y;
        t.pageIndex = 1;
        t.pageSize = 10;
        t.$watch("date", function() { t.refreshDate() }) })() }]);
dashboardModule.directive("dashboardSummaryBlockAdminOfficePanel", ["$log", "loginContext", function(n, t) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/block/dashboard-summary-block-admin-office-panel.html", scope: { blocks: "=", isProtectedMode: "@", configFunc: "=" }, link: function(n) {
            (function() { n.isShowSetButton = t.dashboardType != "WebPhoneConsultant" && !t.isAdminOffice;
                n.$watch("isProtectedMode", function() { n.isProtected = !(n.isProtectedMode == "false") }) })() } } }]);
dashboardModule.directive("dashboardSummaryBlockPanel", ["$log", "loginContext", "enums", "patientUtil", function(n, t, i, r) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/block/dashboard-summary-block-panel.html", scope: { blocks: "=", isProtectedMode: "@", configFunc: "=", refreshFunc: "=" }, link: function(n) { var u = function(t) { var i = !1;
                t == "personage" ? (i = !1, n.selectStatus = "personage") : (i = !0, n.selectStatus = "department");
                n.refreshFunc(i) };
            (function() { n.isShowSetButton = t.isGroup ? !0 : !t.isAdminOffice;
                n.selectStatus = "personage";
                n.isGroup = t.isGroup;
                n.switchStatus = u;
                n.dashboardType = t.dashboardType;
                n.isConsult = t.providerJob == "网电营销";
                n.isDepartmentLevel = r.getPatientPermissionLevel() == i.PatientPermissionLevel.All || r.getPatientPermissionLevel() == i.PatientPermissionLevel.Department;
                n.$watch("isProtectedMode", function() { n.isProtected = !(n.isProtectedMode == "false") }) })() } } }]);
dashboardModule.controller("AccountStatementCtrl", ["$log", "$q", "$scope", "$state", "appNav", "dashboardSvc", "practiceSvc", "dataDicSvc", "loginContext", "aresDialog", "reportSvc", "reportUtil", "systemConfigUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a) { "use strict"; var d = function(n, t) { for (var i = 0; i < n.length; i++)
                if (n[i].payType == t) { n.splice(i, 1); break } },
        p = function() { var n = a.getConfigValue(a.configKeys.IsEnableGiftCard).then(function(n) { i.isEnableGiftCard = n }),
                r = o.officeSettingDic.load().then(function(n) { i.allowUseConsultant = n.isEnableConsultantDiagnose }); return t.all([n, r]) },
        v = function() { l.checkReportDayLimited(i.startTime, i.endTime).then(function() { c.getChargeHistoryPayTypeReport(i.startTime, i.endTime).success(function(n) { i.payTypes = n;
                    f.getAccountStatement(i.startTime, i.endTime, i.accountName).success(function(n) { i.accountStatementSrcData = n;
                        y() }) }) }) },
        y = function() { var u = i.accountStatementSrcData,
                r, f, t, n; for (i.totalget = 0, i.accountStatementList = [], i.accountTotalPrice = [], r = {}, t = 0; t < u.length; ++t) n = u[t], f = n.orderId, r[f] ? r[f] += n.actualPrice : (r[f] = n.actualPrice, i.totalget = i.totalget + n.actualPrice1 + n.actualPrice2 + n.actualPrice3); for (t = 0; t < u.length; ++t) n = u[t], i.providerType == "doctor" ? w(n, r[n.orderId]) : i.providerType == "consultant" && b(n, r[n.orderId]);
            i.accoutDateRange = moment(i.startTime).format("YYYY年MM月DD日 HH点mm分") + " 到 " + moment(i.endTime).format("YYYY年MM月DD日 HH点mm分") },
        g = function(n) { for (var r, u, t, e = !1, f = 0; f < i.accountStatementList.length; ++f)
                if (r = i.accountStatementList[f], r.orderType == n.orderType) { for (e = !0, t = 0; t < i.payTypes.length; ++t) i.payTypes[t].payType == n.payType1 && (r.payTypes[t] = Ares.priceToFixed(n.actualPrice) * 1 + r.payTypes[t], i.accountTotalPrice[t] = i.accountTotalPrice[t] + Ares.priceToFixed(n.actualPrice) * 1, _.find(r.orderSet, function(t) { return t == n.orderId }) == undefined && (r.orderSet.push(n.orderId), r.orderCount = r.orderCount + 1)); break } if (e == !1) { for (u = { name: "", orderCount: 0, orderSet: [], payTypes: [], orderType: n.orderType }, t = 0; t < i.payTypes.length; ++t) u.payTypes.push(0), i.accountTotalPrice.length != i.payTypes.length && i.accountTotalPrice.push(0), i.payTypes[t].payType == n.payType1 && (i.accountTotalPrice[t] = i.accountTotalPrice[t] + Ares.priceToFixed(n.actualPrice) * 1, u.payTypes[t] = Ares.priceToFixed(n.actualPrice) * 1 + u.payTypes[t], u.orderSet.push(n.orderId), u.orderCount = u.orderCount + 1);
                i.accountStatementList.push(u) } },
        w = function(n, t) { for (var f, e, r, s, u, o, c = !1, h = 0; h < i.accountStatementList.length; ++h)
                if (f = i.accountStatementList[h], f.doctorName == n.doctorName && f.orderType == n.orderType) { for (c = !0, r = 0; r < i.payTypes.length; ++r)
                        for (s = i.payTypes[r].payType, u = 1; u < 4; u++) s == n["payType" + u] && (o = n["actualPrice" + u] * n.actualPrice / t * 1, f.payTypes[r] = o + f.payTypes[r], i.accountTotalPrice[r] = i.accountTotalPrice[r] + o, _.find(f.orderSet, function(t) { return t == n.orderId }) == undefined && (f.orderSet.push(n.orderId), f.orderCount = f.orderCount + 1)); break } if (c == !1) { for (e = { doctorName: n.doctorName, orderCount: 0, orderSet: [], payTypes: [], orderType: n.orderType }, r = 0; r < i.payTypes.length; ++r)
                    for (e.payTypes.push(0), i.accountTotalPrice.length != i.payTypes.length && i.accountTotalPrice.push(0), s = i.payTypes[r].payType, u = 1; u < 4; u++) s == n["payType" + u] && (o = n["actualPrice" + u] * n.actualPrice / t * 1, i.accountTotalPrice[r] = i.accountTotalPrice[r] + o, e.payTypes[r] = o + e.payTypes[r], _.find(e.orderSet, function(t) { return t == n.orderId }) == undefined && (e.orderSet.push(n.orderId), e.orderCount = e.orderCount + 1));
                i.accountStatementList.push(e) } },
        b = function(n, t) { for (var f, e, r, s, u, o, c = !1, h = 0; h < i.accountStatementList.length; ++h)
                if (f = i.accountStatementList[h], f.consultantName == n.consultantName && f.orderType == n.orderType) { for (c = !0, r = 0; r < i.payTypes.length; ++r)
                        for (s = i.payTypes[r].payType, u = 1; u < 4; u++) s == n["payType" + u] && (o = n["actualPrice" + u] * n.actualPrice / t * 1, f.payTypes[r] = o + f.payTypes[r], i.accountTotalPrice[r] = i.accountTotalPrice[r] + o, _.find(f.orderSet, function(t) { return t == n.orderId }) == undefined && (f.orderSet.push(n.orderId), f.orderCount = f.orderCount + 1)); break } if (c == !1) { for (e = { consultantName: n.consultantName, orderCount: 0, orderSet: [], payTypes: [], orderType: n.orderType }, r = 0; r < i.payTypes.length; ++r)
                    for (e.payTypes.push(0), i.accountTotalPrice.length != i.payTypes.length && i.accountTotalPrice.push(0), s = i.payTypes[r].payType, u = 1; u < 4; u++) s == n["payType" + u] && (o = n["actualPrice" + u] * n.actualPrice / t * 1, i.accountTotalPrice[r] = i.accountTotalPrice[r] + o, e.payTypes[r] = o + e.payTypes[r], _.find(e.orderSet, function(t) { return t == n.orderId }) == undefined && (e.orderSet.push(n.orderId), e.orderCount = e.orderCount + 1));
                i.accountStatementList.push(e) } },
        k = function() { i.accountStateNumber = moment(new Date).format("YYYYMMDDHHmmsss"); var n = { id: 0, statementNumber: i.accountStateNumber, accountorName: i.accountName, accountorId: s.providerId, accountStartTime: moment(i.startTime).format("YYYY-MM-DD HH:mm:ss"), accountEndTime: moment(i.endTime).format("YYYY-MM-DD HH:mm:ss"), finalPrice: i.totalget, comment: "" };
            f.createAccountStatement(n).success(function(n) { i.confirmedAccountStatement = n;
                h.info("信息", "确认成功！"); return }) };
    (function() { i.accountName = "";
        i.totalget = 0;
        i.accountStateNumber = "";
        i.refresh = v;
        i.saveAccountStatement = k;
        i.refreshView = y; var n = Ares.today();
        i.startTime = moment(n).format("YYYY-MM-DD 01:00:00");
        i.endTime = moment(new Date).format("YYYY-MM-DD HH:mm:ss");
        i.providerType = "doctor";
        i.payTypes = [];
        e.getProvider(s.providerId).success(function(n) { return i.accountName = n.name, p() }).then(function() { v() }) })() }]);
dashboardModule.controller("ApptCancelListCtrl", ["$log", "$scope", "$q", "$modal", "appointmentSvc", "formatUtil", "apptUtil", "patientUtil", "sessionCache", "loginContext", "aresDialog", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; var l = s.getCache(s.keys.DashboardApptCancelListSearchCriteria),
        a = [{ id: 1, text: "今天", value: 0, unit: "d" }, { id: 2, text: "两天内", value: 1, unit: "d" }, { id: 3, text: "三天内", value: 2, unit: "d" }, { id: 4, text: "四天内", value: 3, unit: "d" }, { id: 5, text: "五天内", value: 4, unit: "d" }, { id: 6, text: "六天内", value: 5, unit: "d" }, { id: 7, text: "一周内", value: 1, unit: "w" }, { id: 8, text: "二周内", value: 2, unit: "w" }, { id: 9, text: "三周内", value: 3, unit: "w" }, { id: 10, text: "一个月内", value: 1, unit: "M" }, { id: 11, text: "两个月内", value: 2, unit: "M" }, { id: 12, text: "六个月内", value: 6, unit: "M" }, { id: 13, text: "一年内", value: 1, unit: "y" }, { id: 0, text: "全部", value: -1, unit: "" }, ],
        v = function() { var i = w(),
                n = t.doctorId > -1 ? t.doctorId : null,
                r = { officeId: t.officeId, doctorId: n, isCancelled: !0, stateLastUpdated: i, isPending: !1, department: t.department },
                e = { doctorId: n, id: t.daysBeforeTodayOption.id, value: t.daysBeforeTodayOption.value, unit: t.daysBeforeTodayOption.unit, text: t.daysBeforeTodayOption.text };
            d(e);
            u.searchAppointments(r).success(function(n) { f.formatAppts(n);
                o.formatPatientHeadInfo(n).then(function(n) { t.cancelAppts = n || [] }) }) },
        w = function() { var n = null,
                i; return t.daysBeforeTodayOption && t.daysBeforeTodayOption.id > 0 && (i = Ares.today(), n = moment(i).subtract(t.daysBeforeTodayOption.value, t.daysBeforeTodayOption.unit).format("YYYY-MM-DD")), n },
        b = function(n, i) { if (!e.canCreateAppt()) { c.info("提示", "无创建预约权限"); return } u.getAppointment(n.id).success(function(n) { n.isCancelled = !1; var r = moment(n.startTime).toDate(),
                    u = Ares.today();
                r < u && r.setDatePart(u);
                n.startTime = r;
                o.editFollowUpAppt(n).then(function(n) { n.onlyPatientChanged ? p(n, t.cancelAppts) : y(n);
                    i(n) }) }) },
        y = function(n) { e.removeApptFromApptList(n, t.cancelAppts) },
        p = function(n) { e.refreshApptInApptList(n, t.cancelAppts) },
        k = function() { var n = t.cancelAppts ? t.cancelAppts.length : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        d = function(n) { n != null && (n.startDate && (n.startDate = n.startDate.format("YYYY-MM-DD")), n.endDate && (n.endDate = n.endDate.format("YYYY-MM-DD")), l.saveObject(n)) },
        g = function() { var u = i.defer(),
                n = l.loadObject(),
                r; return _.isEmpty(n) || (t.doctorId = n.doctorId, r = {}, r.id = n.id, r.value = n.value, r.unit = n.unit, r.text = n.text, t.daysBeforeTodayOption = r), u.resolve(!0), u.promise };
    (function() { t.department = h.department;
        t.daysBeforeTodayOptions = a;
        t.daysBeforeTodayOption = a[0];
        t.doctorId = -1;
        t.search = v;
        t.removeAppt = y;
        t.refreshAppt = p;
        t.rebookAppt = b;
        t.updateCount = k;
        g().then(function(n) { v(n) }) })() }]);
dashboardModule.controller("ApptPendingListCtrl", ["$log", "$scope", "$q", "$timeout", "appointmentSvc", "formatUtil", "apptUtil", "patientUtil", "sessionCache", "loginContext", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var y = s.getCache(s.keys.ApptPendingListSearchCriteria),
        c = null,
        l = { daysAfterToday: 1, doctorId: -1, toDate: Ares.tomorrow() },
        w = { startTime: "date", recordCreatedTime: "dateTime" },
        a = function() { var i = moment(t.date).add(1, "d").format("YYYY-MM-DD"),
                r = l.doctorId > -1 ? l.doctorId : null,
                n = { doctorId: r, isPending: !0, endTime: i, department: t.department, pageIndex: t.searchCriteria ? t.searchCriteria.pageIndex : 1, pageSize: t.searchCriteria ? t.searchCriteria.pageSize : 10 };
            b(n);
            t.searchCriteria = n;
            u.searchPagingAppointments(n).success(function(n) { t.pageData = n;
                f.formatAppts(n.items, w);
                o.formatPatientHeadInfo(n.items).then(function(n) { t.pendingAppts = n || [] }) }) },
        b = function(n) { n != null && (n.date = moment(t.date).format("YYYY-MM-DD"), y.saveObject(n)) },
        k = function() { var n = i.defer(),
                r = y.loadObject(); return r && (_.extend(t.criteria, r), t.criteria.date && (t.date = t.criteria.date)), n.resolve(!0), n.promise },
        d = function(n, i) { u.getAppointment(n.id).success(function(n) { var u;
                n.isPending = !1; var f = moment(n.startTime).toDate(),
                    s = e.getMinutes(n),
                    r = e.getDefaultApptTime(s);
                r.startTime.setDatePart(f);
                r.endTime.setDatePart(f);
                u = Ares.today();
                r.startTime < u && (r.startTime.setDatePart(u), r.endTime.setDatePart(u));
                n.startTime = r.startTime;
                n.endTime = r.endTime;
                o.editFollowUpAppt(n).then(function(n) { n && (n.onlyPatientChanged ? p(n, t.pendingAppts) : v(n));
                    i(n) }) }) },
        g = function(t, i) { t.isPending ? e.deletePendingAppt(t).then(function(n) { v(n);
                i(n) }) : n.error("Only pending appt can be deleted.") },
        v = function(n) { e.removeApptFromApptList(n, t.pendingAppts) },
        p = function(n) { e.refreshApptInApptList(n, t.pendingAppts) },
        nt = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        tt = function(n, i) { i = i || "d"; var u = moment(t.date).add(n, i).toDate();
            t.date = u;
            c && r.cancel(c);
            c = r(function() { a() }, 100) };
    (function() { t.department = h.department;
        t.criteria = l;
        t.search = a;
        t.removeAppt = v;
        t.refreshAppt = p;
        t.rebookAppt = d;
        t.deleteAppt = g;
        t.updateCount = nt;
        t.date = Ares.tomorrow();
        t.navigate = tt;
        t.isInitialize = !0;
        k().then(function(n) { a(n) });
        t.$watch("date", function() { t.refreshDate() }) })() }]);
dashboardModule.controller("BirthPatientCtrl", ["$log", "$filter", "$q", "$scope", "appNav", "patientUtil", "shortMessageUtil", "patientSvc", "sessionCache", function(n, t, i, r, u, f, e, o, s) { "use strict"; var h = s.getCache(s.keys.DashboardBirthPatientSearchCriteria);
    r.startDate = moment(new Date).format("MM-DD");
    r.endDate = moment(new Date).add(1, "w").format("MM-DD"); var a = function(n) { u.goToPatient(n.patient.id) },
        c = function() { var n, t, i = r.pageSize || 20,
                u = r.pageIndex || 1,
                f; return r.day == -1 ? (n = moment(new Date).add(-1, "d").format("YYYY-MM-DD"), t = moment(new Date).add(-1, "d").format("YYYY-MM-DD")) : r.day == 0 ? (n = moment(new Date).format("YYYY-MM-DD"), t = moment(new Date).format("YYYY-MM-DD")) : r.day == 1 ? (n = moment(new Date).add(1, "d").format("YYYY-MM-DD"), t = moment(new Date).add(1, "d").format("YYYY-MM-DD")) : (n = moment(r.startDate).format("YYYY-MM-DD"), t = moment(r.endDate).format("YYYY-MM-DD")), f = { day: r.day, startDate: n, endDate: t, pageSize: i, pageIndex: u }, p(f), { startDate: moment(n).format("MM-DD"), endDate: moment(t).add(1, "d").format("MM-DD"), pageIndex: u, pageSize: i } },
        l = function() { var u = i.defer(),
                n = c(); return o.getPatientByBirth(n.startDate, n.endDate, n.pageIndex, n.pageSize).success(function(n) { var e, o, i; for (r.totalCount = n ? n.totalCount : 0, k(), e = n.items, o = t("toSexString"), i = 0; i < e.length; i++) e[i].birth = moment(e[i].birth).format("YYYY-MM-DD"), e[i].firstVisit != null && (e[i].firstVisit = moment(e[i].firstVisit).format("YYYY-MM-DD")), e[i].sex = o(e[i].sex), e[i].phoneNumberAndMask = (e[i].phoneNumber || "") + " " + (e[i].mobile || ""), e[i].patientId = e[i].id, e[i].index = i;
                f.formatPatientHeadInfo(e).then(function(n) { r.patientList = n || [];
                    u.resolve() }) }), u.promise },
        v = function(n) { o.exportPatientByBirth(n) },
        y = function(n, t) { e.sendMessage(n, t) },
        p = function(n) { n != null && (r.day && (n.day = n.day), n.startDate && (n.startDate = n.startDate.format("YYYY-MM-DD")), n.endDate && (n.endDate = n.endDate.format("YYYY-MM-DD")), n.pageSize && (n.pageSize = n.pageSize), n.pageIndex && (n.pageIndex = n.pageIndex), h.saveObject(n)) },
        w = function() { var t = i.defer(),
                n = h.loadObject(); return _.isEmpty(n) || (r.day = n.day, r.startDate = n.startDate, r.endDate = n.endDate, r.pageSize = n.pageSize, r.pageIndex = n.pageIndex), t.resolve(), t.promise },
        b = function() { var n = h.loadObject(); if (!_.isEmpty(n)) return n.pageIndex },
        k = function() { r.$parent && r.$parent.refreshDashboardBlockHint && r.$parent.refreshDashboardBlockHint(r.totalCount) };
    (function() { r.goToPatient = a;
        r.day = 0;
        r.exportToExcel = v;
        r.sendMessage = y;
        r.refresh = l;
        r.getSearchCriteria = c;
        r.getCachedPageIndex = b;
        w().then(function() { l() }) })() }]);
dashboardModule.controller("ChargedPatientCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "appNav", "constants", "appointmentSvc", "dashboardSvc", "formatUtil", "sessionCache", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; var l = c.getCache(c.keys.DashboardChargedPatientSearchCriteria),
        a, y = function() { var n = Ares.today(),
                i = moment(n).add(-1, "week").toDate();
            a = { startDate: i, endDate: n };
            t.timeSpan = _.clone(a) },
        p = function() { var n = t.chargeOrderList ? t.chargeOrderList.length : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        v = function(n) { var r, f, e, i = $("#chargedTodayInput").val(),
                o;
            i == "自定义" ? (r = moment(t.timeSpan.startDate), f = moment(t.timeSpan.endDate).add(1, "d")) : i == "week" ? (r = moment(Ares.today()).startOf("week"), f = moment(Ares.today()).add(1, "d")) : i == "month" ? (r = moment(Ares.today()).startOf("month"), f = moment(Ares.today()).add(1, "d")) : _.isEmpty(n) ? (r = moment(Ares.today()).add(-$("#chargedTodayInput").val(), "d"), f = moment(Ares.today()).add(1, "d")) : (i = n.range, r = moment(n.startDate), f = moment(n.endDate).add(1, "d"), e = n.pid);
            e = e || $("#payeeInput").val();
            e == "" && (e = -1);
            i = i ? i : t.criteria.range;
            o = { range: i, startDate: r, endDate: moment(f).add(-1, "d"), pid: e };
            w(o);
            s.getChargedOrder(r, f, e).success(function(n) { for (var i = 0; i < n.length; ++i) n[i].sexStr = u("toSexString")(n[i].sex), n[i].payDateTimeStr = moment(n[i].payDateTime).format("YYYY-MM-DD HH:mm:ss"), n[i].payTypeStr = n[i].payType, n[i].payType2 != "" && n[i].payType2 != null && (n[i].payTypeStr = n[i].payTypeStr + "," + n[i].payType2), n[i].payType3 != "" && n[i].payType3 != null && (n[i].payTypeStr = n[i].payTypeStr + "," + n[i].payType3);
                t.chargeOrderList = n;
                t.hasPatient = n.length > 0 }) },
        w = function(n) { n != null && (n.startDate && (n.startDate = n.startDate.format("YYYY-MM-DD")), n.endDate && (n.endDate = n.endDate.format("YYYY-MM-DD")), n.payeeId && (n.payeeId = n.payeeId), n.range && (n.range = n.range), l.saveObject(n)) },
        b = function() { var r = i.defer(),
                n = l.loadObject(); return _.isEmpty(n) || (_.extend(t.criteria, n), t.criteria && t.criteria.startDate && (t.timeSpan.startDate = t.criteria.startDate), t.criteria && t.criteria.endDate && (t.timeSpan.endDate = t.criteria.endDate)), r.resolve(n), r.promise };
    (function() { t.criteria = { range: 0 };
        t.refresh = v;
        t.updateCount = p;
        t.hasPatient = !0;
        y();
        b().then(function(n) { v(n) }) })() }]);
dashboardModule.controller("ConfirmationPatientCtrl", ["$log", "$scope", "$q", "$modal", "appointmentSvc", "formatUtil", "shortMessageUtil", "apptUtil", "patientUtil", "sessionCache", "dataDicSvc", "loginContext", "providerSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a) { "use strict"; var p = h.getCache(h.keys.DashboardConfirmationPatientSearchCriteria),
        w, b = function() { var n = Ares.today(),
                i = moment(n).add(1, "d").toDate();
            w = { startDate: n, endDate: i };
            t.timeSpan = _.clone(w) },
        v = function(n) { var i = t.loadCriteria(n),
                r = t.criteria.range ? t.criteria.range : "1",
                e = { range: r, startDate: i.startTime, endDate: moment(i.endTime).add(-1, "d").format("YYYY-MM-DD") };
            ot(e);
            t.searchCriteria = i;
            t.appts = [];
            u.searchPagingAppointments(i).success(function(n) { var i, r, u; if (t.pageData = n, !t.pageData || (t.pageData.items && t.pageData.items.length == 0)) { t.unconfirmedAppts = t.pageData.items;
                    t.hasConfirmation = 0; return } for (i = _.filter(t.pageData.items, { isPlaceholder: !1 }), f.formatAppts(i, { recordCreatedTime: "longDateTime" }), r = 0; r < i.length; r++)
                    for (u = 0; u < t.operatoryData.length; u++) i[r].operatoryId == t.operatoryData[u].id && (i[r].operatoryName = t.operatoryData[u].description);
                i = _.sortBy(i, "startTime");
                s.formatPatientHeadInfo(i).then(function(n) { n = _.filter(n, function(n) { return n.stateStr != "待定" });
                    t.unconfirmedAppts = n;
                    t.hasConfirmation = n.length > 0 }) }) },
        k = function() { var n = i.defer(); return c.operatoryDic.loadActive().then(function(i) { t.operatoryData = i;
                n.resolve(!0) }), n.promise },
        d = function() { var n = i.defer(); return c.consultantDic.loadActive().then(function(i) { t.consultantData = i;
                n.resolve(!0) }), n.promise },
        g = function() { var n = i.defer(); return a.getOtherProvider(!0).success(function(i) { t.createUsers = i;
                n.resolve(i) }), n.promise },
        nt = function(n, t) { Ares.ensureNotDuplicated("confirmAppt") && u.confirmAppointment(n.id).success(function(n) { y(n);
                t(n) }) },
        tt = function(n, t) { Ares.ensureNotDuplicated("unconfirmAppt") && u.unconfirmAppointment(n.id).success(function(n) { y(n);
                t && t(n) }) },
        it = function(n, t) { s.editFollowUpApptById(n.id).then(function(n) { y(n);
                t(n) }) },
        rt = function(n, i) { var u = r.open({ animation: !0, backdrop: "static", template: "<appt-card-lite-view><\/appt-card-lite-view>", controller: "ApptCardLiteCtrl", resolve: { apptHost: function() { return { operation: "cancel", officeId: t.officeId, appointment: n } } } });
            u.result.then(function(n) { v();
                y(n);
                i(n) }) },
        ut = function(n) { o.removeApptFromApptList(n, t.unconfirmedAppts) },
        y = function(n) { var i = t.findAppt(n.id);
            n.appointmentReminderTimes = i.appointmentReminderTimes;
            n.outProcessStatus = i.outProcessStatus;
            o.refreshApptInApptList(n, t.unconfirmedAppts) },
        ft = function(n, t) { e.sendMessage(n, t) },
        et = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        ot = function(n) { n != null && p.saveObject(n) },
        st = function() { var r = i.defer(),
                n = p.loadObject(); return n && (_.extend(t.criteria, n), t.criteria && t.criteria.startDate && (t.timeSpan.startDate = t.criteria.startDate), t.criteria && t.criteria.endDate && (t.timeSpan.endDate = t.criteria.endDate)), r.resolve(n), r.promise },
        ht = function() { var n = i.defer(); return c.userNameDic.load().then(function(i) { var r = _.find(i, function(n) { return n.id == l.userId });
                r && (t.department = r.department);
                n.resolve(!0) }), n.promise },
        ct = function() { t.patientName && v() };
    (function() { t.department = null;
        t.criteria = { range: 1, pageIndex: 1, pageSize: 10 };
        t.daysFromToday = 1;
        t.doctorId = -1;
        t.confirmAppt = nt;
        t.unconfirmAppt = tt;
        t.updateAppt = it;
        t.search = v;
        t.removeAppt = ut;
        t.cancelAppt = rt;
        t.sendMessage = ft;
        t.updateCount = et;
        t.hasConfirmation = !0;
        t.patientSearch = ct;
        b();
        d().then(function() { g().then(function() { k().then(function() { ht().then(function() { c.patientSourceTypeDic.load().then(function() { st().then(function(n) { v(n) }) }) }) }) }) }) })() }]);
dashboardModule.controller("DashboardAdminOfficeAttendantCtrl", ["$log", "$scope", "$modal", "$q", "$state", "aresNotification", "dashboardSvc", "eventAggregator", "appointmentSvc", "patientSvc", "appNav", "constants", "enums", "formatUtil", "practiceSvc", "reportSvc", "officeSvc", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) { "use strict"; var g = function(n, t, i, r, u) { this.name = n;
            this.configName = t;
            this.stateName = i;
            this.icon = r;
            this.hintFunc = u;
            this.visible = !0 },
        ft = { userId: b.userId, sumType: "今日" },
        nt = null,
        tt = null,
        k = moment(Ares.today()).format("YYYY-MM-DD"),
        d = moment(Ares.today()).add(1, "d").format("YYYY-MM-DD"),
        et = function() { var n = r.defer(); return w.loadSetting().then(function(i) { t.officeSetting = i; var r = _.find(i.systemConfigs, { configName: "AllowStatement" });
                t.allowStatement = r && r.configValue.toUpperCase() == "TRUE" ? !0 : !1;
                n.resolve() }), n.promise },
        ot = function() { nt = [new DashboardBlock("今日预约", "newRegister", "icon-user-follow", 10, !1, null, "#00b39c"), new DashboardBlock("回访量", "newAppointment", "icon-plus", 20, !1, null, "#5296d8"), new DashboardBlock("新预约", "newAppointment", "icon-plus", 20, !1, null, "#5296d8"), new DashboardBlock("新患者", "newAppointment", "icon-plus", 20, !1, null, "#5296d8"), new DashboardBlock("新成交", "newAppointment", "icon-plus", 20, !1, null, "#5296d8"), ];
            tt = [new g("今日预约", "todayAdminOfficeAppointment", "dashBoard.todayAdminOfficeAppointment", "icon-user", null), new g("今日回访", "todayAdminOfficeRevisit", "dashBoard.todayAdminOfficeRevisit", "glyphicon glyphicon-list-alt", null), ] },
        vt = function() { c.switchState("apptMgmt.apptList", { isCreateTime: !0 }) },
        yt = function() { c.goToState("patientCenter.patientList.search") },
        pt = function() { c.switchState("shortMessage.history", { status: "发送失败" }) },
        wt = function() { c.switchState("shortMessage.history", { status: "发送成功" }) },
        bt = function() { c.switchState("shortMessage.feedback") },
        st = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<my-achievements-setting-view><\/my-achievements-setting-view>", controller: "MyAchievementsSettingCtrl", windowClass: "myachievemnet-setting-dialog", size: "sm", resolve: { host: function() { return null } } });
            n.result.then(function(n) { n && (e.clearConfigCache("MyAchivement"), e.clearConfigCache("Dashboard"), it()) }) },
        ht = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<today-work-setting-view><\/today-work-setting-view>", controller: "TodayWorkSettingCtrl", windowClass: "show-today-work-dialog", size: "lg" });
            n.result.then(function(n) { n && e.clearConfigCache("Dashboards") }) },
        it = function() { var n = [];
            e.getAdminSumByFilter(ft).success(function(i) { angular.forEach(i, function(t) { var r = _.find(nt, { type: t.itemName }),
                        i;
                    r && (i = _.clone(r), i.value = t.itemValue, i.text = t.itemName, n.push(i)) });
                n = _.sortBy(n, "showOrder");
                t.summaryBlocks = n }) },
        kt = function(n) { var i = r.defer(),
                u = { officeId: t.officeId, startTime: moment(k).format(l.dateFormat), endTime: moment(k).add(1, "d").format(l.dateFormat), isCancelled: !1 }; return s.countAppointments(u).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        dt = function(n) { var t = r.defer(); return e.getChargeOrderCount(k, d, !1).success(function(i) { i && (n.hintWarn = i.unChargedOrderCountOfToday, n.hint = i.unChargedOrderCount);
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        gt = function(n) { var t = r.defer(); return e.getChargeOrderCount(k, d, !0).success(function(i) { n.hint = i.chargedOrderCount;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        ni = function(n) { var i = r.defer(),
                t = { statusType: -1, startTime: k, endTime: d, isInactive: !1, doctorId: -1 }; return p.countFollowupDoctorReport(t.statusType, t.startTime, t.endTime, t.doctorId, t.isInactive).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        ti = function(n) { var i = r.defer(),
                u = { officeId: t.officeId, doctorId: rt(), startTime: d, endTime: moment(d).add(1, "d").format("YYYY-MM-DD"), isCancelled: !1, isPending: !1 }; return s.countAppointments(u).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        ii = function(n) { var i = r.defer(),
                u = { officeId: t.officeId, doctorId: rt(), isCancelled: !0, stateLastUpdated: k, isPending: !1 }; return s.countAppointments(u).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        ri = function(n) { var t = r.defer(),
                i = moment(k).add(2, "day"),
                u = { endTime: i.format("YYYY-MM-DD"), isPending: !0 }; return s.countAppointments(u).success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        ui = function(n) { var t = r.defer(); return h.countPatientByBirth(k, d).success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        fi = function(n) { var t = r.defer(),
                i = { startTime: moment(k).add(-7, "d").format("YYYY-MM-DD"), endTime: d }; return s.countAppointmentApplys(i).success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        ei = function(n) { var t = r.defer(); return p.stockItemRemindCount().success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        rt = function() { return t.doctorId > -1 ? t.doctorId : null },
        ct = function() { o.subscribe(t, o.events.ChargeOrderChanged, ut);
            o.subscribe(t, o.events.ChargeOrderCreated, ut) },
        ut = function() { f.playSound();
            refreshChargeBlockHint() },
        lt = function(n, i) { var f = u.current.name,
                r = _.find(t.listBlocks, { stateName: f });
            r && (r.hint = n, i != undefined && (r.hintWarn = i)) },
        at = function() { t.listBlocks = tt };
    (function() { t.showMyAchievementsSettingDialog = st;
        t.showTodayWorkSettingDialog = ht;
        t.refreshDashboardBlockHint = lt;
        ct();
        ot();
        et().then(function() { at() });
        it() })() }]);
dashboardModule.controller("DashboardAdminOfficeCtrl", ["$log", "$scope", "$modal", "$q", "$state", function() { "use strict";
    (function() {})() }]);
dashboardModule.controller("DashboardDoctorCtrl", ["$log", "$scope", "$modal", "$filter", "$timeout", "dashboardSvc", "appNav", "formatUtil", "loginContext", "patientUtil", "apptUtil", "appointmentSvc", "reportSvc", "eventAggregator", "practiceSvc", "$q", "officeOptionSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w) { "use strict"; var b = { providerId: s.doctorId, sumType: "今日" },
        d = function() { var n = p.defer(); return w.getOfficeOption(w.optionKeys.IsMedicalLiabilityInsuranceEnabled).then(function(i) { t.IsMedicalLiabilityInsuranceEnabled = i;
                n.resolve() }), n.promise },
        g = [new DashboardBlock("新增预约", null, "icon-plus bg-blue", 10), new DashboardBlock("处方总数", null, "icon-layers bg-green", 20), new DashboardBlock("病历书写", null, "icon-docs bg-purple", 30), new DashboardBlock("待完成病历任务", null, "icon-docs bg-purple2", 31), new DashboardBlock("随访人次", null, "icon-emoticon-smile bg-pink", 40), new DashboardBlock("实收金额", null, "glyphicon glyphicon-yen bg-orange", 50, !0), new DashboardBlock('"即刻Smile"保障中', null, "iconfont icon-wangguan  bg-orange2", 60, !1), new DashboardBlock('"即刻Smile"待上传病历', null, "iconfont icon-jiantouxiangshang  bg-blue3", 70, !1)],
        nt = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<my-achievements-setting-view><\/my-achievements-setting-view>", controller: "MyAchievementsSettingCtrl", windowClass: "private-id-rule-edit-dialog", size: "lg", resolve: { host: function() { return null } } });
            n.result.then(function(n) { n && k() }) },
        tt = function() { f.getDoctorSumByFilter(b).success(function(n) { var i = [],
                    r = it(n),
                    u = _.find(n, { itemName: "即刻Smile保障总额度" });
                angular.forEach(n, function(n) { var f = _.find(g, { type: n.itemName }),
                        t;
                    f && (t = _.clone(f), t.value = n.itemValue, n.itemName === '"即刻Smile"保障中' || n.itemName === '"即刻Smile"待上传病历' ? (t.text = n.itemName, t.hideBlock = r, rt(t, u.itemValue)) : n.itemName === "待完成病历任务" ? (t.onClick = ft, t.text = b.sumType + n.itemName) : t.text = b.sumType + n.itemName, i.push(t)) });
                i = _.sortBy(i, "showOrder");
                t.summaryBlocks = i }) },
        it = function() { return t.IsMedicalLiabilityInsuranceEnabled ? !1 : !0 },
        rt = function(n, t) { if (n.onClick = ut, n.text === '"即刻Smile"保障中') { var i = t - n.value;
                n.title = i > 5 ? '当前"即刻Smile"保障额度：' + t + " ，剩余数量：" + i + "。" : 0 < i && i <= 5 ? '当前"即刻Smile"保障额度：' + t + " ，剩余数量：" + i + "，您享有的“即刻Smile”的种植体即将使用完毕。" : '当前"即刻smile"保险保障额度已用完。NOBEL ACTIVE种植体将无保险覆盖，请与您的经销商联系。' } n.text === '"即刻Smile"待上传病历' && (n.title = "请在48小时内完善病历、全景片、CBCT内容并上传，保障保险权益。") },
        ut = function() { e.goToState("openPlatformCenter", { action: "mli" }) },
        ft = function() { e.goToState("pendingMedicalrecord") },
        k = function() { y.getSystemConfigByType("Dashboard").success(function(n) { var i = _.find(n, { configName: "protectionAmount" }),
                    r = !1;
                i && (r = i.configValue.toLowerCase() == "true");
                t.isProtectedMode = r }) },
        et = function() { var i, n, r; if (s.dashboardRoleType != "牙医" && s.dashboardRoleType != "学生" || s.roleDashboardConfig)
                for (i = s.roleDashboardConfig.ConfigData[0].Items, n = 0; n < i.length; n++) r = i[n].Value.toLowerCase() == "true", i[n].Name == "todayCheck" ? t.isTodayCheckShow = r : t.isFollowupShow = r;
            else t.isTodayCheckShow = !0, t.isFollowupShow = !0 };
    (function() { t.isProtectedMode = !0;
        t.showMyAchievementsSettingDialog = nt;
        k();
        d().then(function() { tt() });
        t.isTodayCheckShow = !1;
        t.isFollowupShow = !1;
        et() })() }]);
dashboardModule.controller("DashboardFrontConsultantCtrl", ["$log", "$scope", "$modal", "aresNotification", "dashboardSvc", "eventAggregator", "appointmentSvc", "patientSvc", "appNav", "constants", "enums", "formatUtil", "practiceSvc", "reportSvc", "officeSvc", function() { "use strict";
    (function() {})() }]);
dashboardModule.controller("DashboardFrontCtrl", ["$log", "$scope", "$modal", "$q", "$state", "aresNotification", "dashboardSvc", "eventAggregator", "appointmentSvc", "patientSvc", "appNav", "constants", "enums", "formatUtil", "practiceSvc", "reportSvc", "officeSvc", "officeOptionSvc", "loginContext", "dataDicSvc", "healthInsuranceSvc", "patientUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g) { "use strict"; var tt = function(n, t, i, r, u) { this.name = n;
            this.configName = t;
            this.stateName = i;
            this.icon = r;
            this.hintFunc = u;
            this.visible = !0 },
        at = { providerId: 0, sumType: "今日", department: k.department },
        rt = null,
        nt = null,
        it = moment(Ares.today()).format("YYYY-MM-DD"),
        ut = moment(Ares.today()).add(1, "d").format("YYYY-MM-DD"),
        vt = function() { var n = r.defer(); return w.loadSetting().then(function(i) { t.officeSetting = i; var r = _.find(i.systemConfigs, { configName: "AllowStatement" });
                t.allowStatement = r && r.configValue.toUpperCase() == "TRUE" ? !0 : !1;
                n.resolve() }), n.promise },
        yt = function() { rt = [new DashboardBlock("新增患者", "newRegister", "icon-user-follow", 10, !1, bt, "#00b39c"), new DashboardBlock("新增预约", "newAppointment", "icon-plus", 20, !1, wt, "#5296d8"), new DashboardBlock("今日就诊", "todayVisit", "icon-plus", 30, !1, null, "#5296d8"), new DashboardBlock("实收金额", "totalCharge", "glyphicon glyphicon-yen", 40, !0, null, "#f8b16d"), new DashboardBlock("随访人次", "followupCount", "icon-emoticon-smile", 50, !1, null, "#7ed321"), new DashboardBlock("短信", "smsCount", "glyphicon glyphicon-envelope", 60, !1, ot, "#d161a1")];
            nt = [new tt("今日就诊", "todayCheck", "dashBoard.todayCheck", "icon-user", ri), new tt("今日对账", "todayAccount", "dashBoard.todayAccount", "icon-diamond", null), /*new tt("待收费", "uncharge", "dashBoard.uncharge", "icon-cloud-download", ui), new tt("已收费", "charged", "dashBoard.charged", "icon-calculator", fi),*/ new tt("今日随访", "followup", "dashBoard.followup", "glyphicon glyphicon-list-alt", ei), new tt("今日回访", "todayRevisit", "dashBoard.groupTodayRevisit", "glyphicon glyphicon-list-alt", bi), new tt("明日预约", "unconfirmAppt", "dashBoard.unconfirmAppt", "icon-basket", si), new tt("预约已取消", "cancelAppt", "dashBoard.cancelAppt", "icon-check", hi), new tt("待定预约", "pendingAppt", "dashBoard.pendingAppt", "icon-check", ci), new tt("生日提醒", "brith", "dashBoard.brith", "icon-check", li), new tt("商保", "healthInsurance", "dashBoard.healthInsurance", "icon-check", wi), new tt("医保对账", "yibaoInsuranceBillCheck", "dashBoard.yibaoInsuranceBillCheck", "icon-check", null), ];
            k.isProfessional || nt.push(new tt("网络预约", "appointApply", "dashBoard.appointApply", "icon-feed", ai));
            /*nt.push(new tt("有效期预警", "expirationRemind", "dashBoard.expirationRemind", "icon-feed", vi)) */},
        pt = function() { var o = r.defer(),
                u, n, s, e, i, f, h; if (t.dashboardConfig)
                for (u = 0; u < t.dashboardConfig.length; u++)
                    for (n = nt.length - 1; n >= 0; n--) s = nt[n], e = t.dashboardConfig[u], s.configName == e.Name && e.Value.toUpperCase() == "FALSE" && nt.splice(n, 1);
            else
                for (i = nt.length - 1; i >= 0; i--) nt[i].configName == "todayRevisit" && nt.splice(i, 1); return t.dashboardSummaryBlocks && t.dashboardSummaryBlocks.length > 0 && (f = _.filter(t.dashboardSummaryBlocks, { Value: "true" }), t.isShowBlock = f && f.length > 0, t.isShowBlock ? (h = _.pluck(f, "Name"), rt = _.filter(rt, function(n) { return _.indexOf(h, n.configName) > -1 ? !0 : !1 })) : rt = []), b.getOfficeOptions([b.optionKeys.IsShangbaoEnabled, b.optionKeys.IsYibaoGatewayEnabled, b.optionKeys.IsYibaoBillCheckEnabled]).then(function(n) { var i = et(n[0]),
                    r = et(n[1]),
                    u = et(n[2]),
                    t; if (!i)
                    for (t = 0; t < nt.length; t++)
                        if (nt[t].configName == "healthInsurance") { nt.splice(t, 1); break } if (!r || !u)
                    for (t = 0; t < nt.length; t++)
                        if (nt[t].configName == "yibaoInsuranceBillCheck") { nt.splice(t, 1); break } o.resolve() }), o.promise },
        et = function(n) { var t = !1; return _.isBoolean(n) ? t = n : _.isString(n) && (n === "1" || n.toLowerCase() === "true") && (t = !0), t },
        wt = function() { window.Ares3 && !k.isGroup ? c.goToState("new", { route: "appointment.list" }) : c.switchState("apptMgmt.apptList", { isCreateTime: !0 }) },
        bt = function() { c.goToState("patientCenter.patientList.search") },
        kt = function() { c.switchState("shortMessage.history", { status: "发送失败" }) },
        ot = function() { c.switchState("shortMessage.history", { status: "发送成功" }) },
        dt = function() { c.switchState("shortMessage.feedback") },
        gt = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<my-achievements-setting-view><\/my-achievements-setting-view>", controller: "MyAchievementsSettingCtrl", windowClass: "myachievemnet-setting-dialog", size: "sm", resolve: { host: function() { return { frontSummaryBlockDic: rt } } } });
            n.result.then(function(n) { n && (e.clearConfigCache("MyAchivement"), e.clearConfigCache("Dashboard"), st()) }) },
        ni = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<today-work-setting-view><\/today-work-setting-view>", controller: "TodayWorkSettingCtrl", windowClass: "show-today-work-dialog", size: "lg", resolve: { dashboardConfig: function() { return t.dashboardConfig } } });
            n.result.then(function(n) { n && (e.clearConfigCache("Dashboards"), ht()) }) },
        st = function() { e.loadConfig("Dashboard").then(function(n) { var i = _.find(n, { configName: "protectionAmount" }),
                    r = !1;
                i && (r = i.configValue.toLowerCase() == "true");
                t.isProtectedMode = r });
            e.loadConfig("MyAchivement").then(function(n) { var r = 1,
                    i;
                angular.forEach(n, function(n) { var t = _.find(rt, { configName: n.configName });
                    t && (t.showOrder = r++, t.visible = n.configValue.toUpperCase() == "TRUE") });
                i = [];
                e.getFrontSumByFilter(at).success(function(n) { var e = 0,
                        o = 0,
                        s = 0,
                        h, c, l, u, f, r;
                    angular.forEach(n, function(n) { var r = _.find(rt, { type: n.itemName }),
                            t;
                        r && r.visible && (t = _.clone(r), t.value = n.itemValue, t.text = n.itemName, i.push(t));
                        n.itemName == "发送短信" && (e = n.itemValue);
                        n.itemName == "失败短信" && (o = n.itemValue);
                        n.itemName == "回复短信" && (s = n.itemValue);
                        n.itemName === "初诊" && (h = n.itemValue);
                        n.itemName === "复诊" && (c = n.itemValue);
                        n.itemName === "总诊" && (l = n.itemValue) });
                    u = _.find(rt, { type: "短信" });
                    u && u.visible && (r = _.clone(u), r.text = "短信", r.values = [e, o, s], r.funcs = [ot, kt, dt], i.push(r));
                    f = _.find(rt, { type: "今日就诊" });
                    f && f.visible && (r = _.clone(f), r.text = "今日就诊", r.values = [h, c, l], i.push(r));
                    i = _.sortBy(i, "showOrder");
                    t.summaryBlocks = i }) }) },
        ht = function() { var n = r.defer(); return e.loadConfig("Dashboards").then(function(i) { var u, f, r, e, o;
                t.allowStatement || (u = _.find(nt, { name: "今日对账" }), nt = _.without(nt, u));
                f = 1;
                angular.forEach(i, function(n) { var t = _.find(nt, { configName: n.configName });
                    t && (t.showOrder = f++, t.visible = n.configValue.toUpperCase() == "TRUE") });
                r = [];
                e = _.filter(nt, { visible: !0 });
                angular.forEach(e, function(n) { var t = _.clone(n);
                    r.push(t) });
                r = _.sortBy(r, "showOrder");
                o = _.filter(r, function(n) { return n.configName == "uncharge" || n.configName == "charged" });
                t.listBlocks = r;
                t.chargeListBlocks = o;
                t.followupBlocks = _.filter(r, function(n) { return n.configName == "followup" });
                ft();
                n.resolve() }), n.promise },
        ft = function(n, i) { if (n = n || t.listBlocks, i = i || 0, i < n.length) { var r = n[i],
                    u = i + 1;
                r.hintFunc ? r.hintFunc(r).then(function() { ft(n, u) }) : ft(n, u) } },
        ti = function() { ft(t.chargeListBlocks, 0) },
        ii = function() { ft(t.followupBlocks, 0) },
        ri = function(n) { var i = r.defer(),
                u = { officeId: t.officeId, department: k.department, startTime: moment(it).format(l.dateFormat), endTime: moment(it).add(1, "d").format(l.dateFormat), isCancelled: !1 }; return s.countAppointments(u).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        ui = function(n) { var t = r.defer(); return e.getChargeOrderCount(it, ut, !1).success(function(i) { i && (n.hintWarn = i.unChargedOrderCountOfToday, n.hint = i.unChargedOrderCount);
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        fi = function(n) { var t = r.defer(); return e.getChargeOrderCount(it, ut, !0).success(function(i) { n.hint = i.chargedOrderCount;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        ei = function(n) { var i = r.defer(),
                t = { statusType: -1, startTime: it, endTime: ut, isInactive: !1, doctorId: -1 }; return p.countFollowupDoctorReport(t.statusType, t.startTime, t.endTime, t.doctorId, t.isInactive).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        oi = function() { var n = r.defer(); return d.userNameDic.load().then(function(t) { var i = _.find(t, function(n) { return n.id == k.userId }),
                    r = i ? i.department : null;
                n.resolve(r) }), n.promise },
        si = function(n) { var i = r.defer(); return oi().then(function(r) { var u = { officeId: t.officeId, doctorId: ct(), startTime: ut, endTime: moment(ut).add(1, "d").format("YYYY-MM-DD"), isCancelled: !1, isPending: !1, department: r };
                s.countAppointments(u).success(function(t) { n.hint = t;
                    i.resolve() }).error(function() { i.resolve() }) }), i.promise },
        hi = function(n) { var i = r.defer(),
                u = { officeId: t.officeId, doctorId: ct(), isCancelled: !0, stateLastUpdated: it, isPending: !1 }; return s.countAppointments(u).success(function(t) { n.hint = t;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        ci = function(n) { var t = r.defer(),
                i = moment(it).add(2, "day"),
                u = { endTime: i.format("YYYY-MM-DD"), isPending: !0 }; return s.countAppointments(u).success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        li = function(n) { var t = r.defer(); return h.countPatientByBirth(it, ut).success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        ai = function(n) { var t = r.defer(),
                i = { startTime: moment(it).format("YYYY-MM-DD"), endTime: ut }; return s.countAppointmentApplys(i).success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        ki = function(n) { var t = r.defer(); return p.stockItemRemindCount().success(function(i) { n.hint = i;
                t.resolve() }).error(function() { t.resolve() }), t.promise },
        vi = function(n) { var t = r.defer(); return b.getOfficeOption(b.optionKeys.IsInventoryValidityWarnEnabled).then(function(i) { i ? b.getOfficeOption(b.optionKeys.InventoryValidityWarnDayOffset).then(function(i) { var r = i,
                        u = { warehouseId: 0, dayOffset: r ? r : 0 };
                    p.stockItemExpirtaionRemindCount(u).success(function(i) { n.hint = i;
                        t.resolve() }).error(function() { t.resolve() }) }) : (n.hint = 0, t.resolve()) }), t.promise },
        ct = function() { return t.doctorId > -1 ? t.doctorId : null },
        yi = function() { o.subscribe(t, o.events.ChargeOrderChanged, lt);
            o.subscribe(t, o.events.ChargeOrderCreated, lt) },
        lt = function() { ti() },
        pi = function(n, i) { var f = u.current.name,
                r = _.find(t.listBlocks, { stateName: f });
            r && (r.hint = n, i != undefined && (r.hintWarn = i)) },
        wi = function(n) { var t = r.defer(); return g.getTodoCount().then(function(i) { var r = i.data;
                r && (n.hint = r.totalCount, n.hintWarn = r.processCount);
                t.resolve() }), t.promise },
        bi = function(n) { var t = r.defer(),
                i = { startDate: moment(it).format("YYYY-MM-DD"), endDate: moment(it).add(1, "day").format("YYYY-MM-DD"), state: -1, officeId: k.isGroup ? -1 : k.officeId, pageIndex: 1, pageSize: 1, selectCode: "", userId: -1, level: 0 }; return e.getGroupRevisit(i).success(function(i) { n.hint = i.totalCount;
                t.resolve() }).error(function() { t.resolve() }), t.promise };
    (function() { t.showMyAchievementsSettingDialog = gt;
        t.showTodayWorkSettingDialog = ni;
        t.refreshDashboardBlockHint = pi;
        t.isShowBlock = !0;
        yi();
        yt();
        t.dashboardConfig = k.roleDashboardConfig ? k.roleDashboardConfig.ConfigData[0].Items : null;
        t.dashboardSummaryBlocks = k.roleDashboardConfig ? k.roleDashboardConfig.ConfigData[0].Blocks : null;
        t.refreshFollowupBlockHint = ii;
        pt().then(function() { return vt() }).then(function() { return ht() }).then(function() { t.listBlocks && t.listBlocks.length > 0 && t.initView() });
        st() })() }]);
dashboardModule.controller("DashboardHealthInsuranceUploadCtrl", ["$log", "$scope", "$modalInstance", "host", function(n, t, i, r) { "use strict"; var u = function() { i.close() };
    (function() { t.todoItem = r.todoItem;
        t.confirm = u })() }]);
dashboardModule.controller("DashboardTodayAccountCheckCtrl", ["$log", "$scope", "$timeout", "$q", "permissionProvider", "reportSvc", "practiceSvc", "formatUtil", "reportUtil", "printUtil", function(n, t, i, r, u, f, e, o, s, h) { "use strict";
    t.searchCriteria = {}; var a = function() { var n, i; if (t.isAllowViewAccountCheck) n = moment().subtract(1, "week").format("YYYY-MM-DD"), i = moment().add(1, "day").format("YYYY-MM-DD"), t.timeSpan = { startDate: n, endDate: i };
            else { var r = Ares.today(),
                    u = moment(r).toDate(),
                    f = { startDate: u, endDate: r };
                t.timeSpan = _.clone(f) } },
        v = function() { t.searchCriteria.startTime = t.timeSpan.startDate;
            t.searchCriteria.endTime = t.timeSpan.endDate;
            t.searchCriteria.pageSize = 20;
            t.searchCriteria.pageIndex = 1 },
        c = function(n) { var u = r.defer(); return l(t.searchCriteria), s.checkReportDayLimited(t.searchCriteria.startDate, t.searchCriteria.endDate).then(function() { f.chargeAccountCheckReport(t.searchCriteria.startDate, t.searchCriteria.endDate, t.searchCriteria.feeTypes, t.searchCriteria.pageIndex, t.searchCriteria.pageSize).success(function(r) { y(r, n);
                    t.chargeAccountCheckResult = r;
                    i(function() { t.initTableView() }) }) }), u.promise },
        y = function(n, i) { i && n && n.items && t.selectedChargeOrderIds && angular.forEach(n.items, function(n) { var i = _.findIndex(t.selectedChargeOrderIds, function(t) { return t == n.id });
                n.isChecked = i >= 0 ? !0 : !1 }) },
        l = function(n) { var i = t.timeSpan.startDate,
                r = moment(t.timeSpan.endDate).add(1, "d"),
                u = t.getFeeTypes();
            n.startDate = i;
            n.endDate = r;
            n.feeTypes = u },
        p = function() { v();
            c() },
        w = function(n, i) { i = i || "d"; var r = moment(t.timeSpan.startDate).add(n, i).toDate();
            t.timeSpan.startDate = r },
        b = function() { f.chargeAccountCheckReport(t.searchCriteria.startDate, t.searchCriteria.endDate, t.searchCriteria.feeTypes, 1, 1e4).success(function(n) { t.allChargeOrders = n;
                i(function() { h.printElem("account-check-container-print-div") }, 1e3) }) };
    (function() { t.isAllowViewAccountCheck = u.isAllowed("finance.everydayCheckViewMutiDayData");
        t.pageIndex = 1;
        t.pageSize = 20;
        t.maxPageCount = 10;
        t.navigate = w;
        a();
        t.search = c;
        t.init = p;
        t.printChargeOrder = b;
        t.setCriteria = l })() }]);
dashboardModule.controller("DashboardCtrl", ["$log", "$scope", "dashboardSvc", "roleSvc", "enums", "formatUtil", "loginContext", "$q", "$stateParams", function(n, t, i, r, u, f, e) { "use strict";
    (function() { t.dashboardType = e.dashboardType;
        t.isGroup = e.isGroup;
        t.isShow = e.isGroup && (e.roles.indexOf("网电咨询师") > -1 || e.roles.indexOf("网电主管") > -1) })() }]);
dashboardModule.controller("FollowupPatientCtrl", ["$log", "$filter", "$q", "followupSvc", "$scope", "$modal", "appNav", "aresDialog", "reportSvc", "$timeout", "patientUtil", "sessionCache", function(n, t, i, r, u, f, e, o, s, h, c, l) { "use strict"; var p = l.getCache(l.keys.DashboardFollowupPatientSearchCriteria),
        y = null,
        k = function(n) { e.goToPatient(n.patient.id) },
        a = function() { var n = moment(u.date).format("YYYY-MM-DD"),
                t = moment(u.date).add(1, "d").format("YYYY-MM-DD"); return { startDate: n, endDate: t, isInactive: u.searchCriteria.isInactive, statusType: u.searchCriteria.statusType, doctorId: u.searchCriteria.doctorId || -1, consultantId: u.searchCriteria.consultantId || -1, otherProviderId: u.searchCriteria.otherProviderId || -1, searchText: u.searchCriteria.searchText, date: u.date, curTab: u.currentToggleTab } },
        v = function(n) { n && n.date || (n = a());
            w(n);
            s.getFollowupDoctorReport(n).success(function(n) { for (var t = 0; t < n.length; t++) n[t].visitDateTime = moment(n[t].visitDateTime).format("YYYY-MM-DD") || moment(new Date()).format("YYYY-MM-DD"), n[t].executeTime && (n[t].executeTime = moment(n[t].executeTime).format("YYYY-MM-DD")), n[t].mobileAndPhoneNumberMark = (n[t].phoneNumber || "") + " " + (n[t].mobile || "");
                c.formatPatientHeadInfo(n).then(function(n) { u.followupPatList = n || [];
                    b() }) }) },
        d = function(n) { o.confirm("删除随访记录", "确定要删除此随访记录？").then(function() { r.deleteFollowup(n).success(function() { var n = a();
                    v(n) }).error(function(n) { alert(n.data) }) }) },
        g = function(n, t) { t = t || "d"; var i = moment(u.date).add(n, t).toDate();
            u.date = i;
            y && h.cancel(y);
            y = h(function() { var n = a();
                v(n) }, 100) },
        w = function(n) { n != null && p.saveObject(n) },
        nt = function() { var t = i.defer(),
                n = p.loadObject(); return n ? (_.extend(u.searchCriteria, n), n.date && (u.date = n.date), n.curTab && (u.currentToggleTab = n.curTab)) : u.searchCriteria = a(), t.resolve(u.searchCriteria), t.promise },
        tt = function() { var n = u.followupPatList ? u.followupPatList.length : 0;
            u.$parent && u.$parent.refreshDashboardBlockHint && u.$parent.refreshDashboardBlockHint(n) },
        b = function() { var n = [],
                t;
            u.allCompleteCount = u.followupPatList.length;
            u.currentToggleTab == "AllCompleteTab" || u.currentToggleTab == "CompleteTab" ? (t = _.filter(u.followupPatList, function(n) { return n.status != "待计划" }), u.completeCount = t ? t.length : 0, u.notCompleteCount = u.allCompleteCount - u.completeCount, n = u.currentToggleTab == "AllCompleteTab" ? u.followupPatList : t) : (n = _.filter(u.followupPatList, function(n) { return n.status == "待计划" }), u.notCompleteCount = n ? n.length : 0, u.completeCount = u.followupPatList.length - u.notCompleteCount);
            u.filterFollowups = n },
        it = function(n) { n !== u.currentToggleTab && (u.currentToggleTab = n, b(), u.searchCriteria = a(), w(u.searchCriteria)) },
        rt = function(n) { var t = f.open({ animation: !0, backdrop: "static", template: "<operation-log-list-view><\/operation-log-list-view>", controller: "OperationLogListCtrl", size: "lg", windowClass: "operation-log-dialog", resolve: { host: function() { return { id: n, type: "Followup" } } } }) };
    (function() { u.searchCriteria = { statusType: "-1", isInactive: !1, searchText: "" };
        u.goToPatient = k;
        u.refresh = v;
        u.deleteFollowup = d;
        u.date = Ares.today();
        u.navigate = g;
        u.isInitialized = !0;
        u.updateCount = tt;
        u.toggleStateSelection = it;
        u.currentToggleTab = "AllCompleteTab";
        u.completeCount = 0;
        u.notCompleteCount = 0;
        u.showFollowupAuditLog = rt;
        u.loadSearchCriteria = a;
        nt().then(function(n) { v(n) });
        u.$watch("date", function() { u.refreshDate() }) })() }]);
dashboardModule.controller("MyAchievementsSettingCtrl", ["$log", "$scope", "$modalInstance", "loginContext", "practiceSvc", "dashboardSvc", "$q", "host", function(n, t, i, r, u, f, e, o) { "use strict";
    t.protection = {}; var s = !1,
        a = function() { r.isGroup && r.providerJob == "网电营销" ? t.isFrontOperator = !0 : r.dashboardType == "Doctor" ? t.isFrontOperator = !1 : r.dashboardType == "FrontDesk" ? t.isFrontOperator = !0 : r.dashboardType == "WebPhoneConsultant" && (t.isFrontOperator = !1);
            t.isFrontOperator ? (t.showMyAchievement = !0, r.isGroup && r.providerJob == "网电营销" ? u.getSystemConfigByType("GroupMyAchivement").success(function(n) { if (o && (n = c(n, "GroupMyAchivement")), n.length > 0) { var i = 1;
                    angular.forEach(n, function(n) { n.configValue = n.configValue.toUpperCase() == "TRUE" ? !0 : !1;
                        (n.displayOrder == null || n.displayOrder != i) && (n.displayOrder = i);
                        i = i + 1 });
                    u.getSystemConfigByType("Dashboard").success(function(n) { n.length > 0 && angular.forEach(n, function(n) { n.configName == "protectionAmount" && (t.protection = n, t.protection.configValue = n.configValue.toUpperCase() == "TRUE" ? !0 : !1) }) });
                    t.myAchivement = n;
                    t.isShowProtection = _.any(t.myAchivement, { configName: "totalCharge" });
                    s = !0;
                    t.hasChanged = !0 } else t.protection.configName = "protectionAmount", t.protection.configValue = !1, t.protection.coments = "", t.protection.configType = "Dashboard" }) : u.getSystemConfigByType("MyAchivement").success(function(n) { if (o && (n = c(n, "MyAchivement")), n.length > 0) { var i = 1;
                    angular.forEach(n, function(n) { n.configValue = n.configValue.toUpperCase() == "TRUE" ? !0 : !1;
                        (n.displayOrder == null || n.displayOrder != i) && (n.displayOrder = i);
                        i = i + 1 });
                    u.getSystemConfigByType("Dashboard").success(function(n) { n.length > 0 && angular.forEach(n, function(n) { n.configName == "protectionAmount" && (t.protection = n, t.protection.configValue = n.configValue.toUpperCase() == "TRUE" ? !0 : !1) }) });
                    t.myAchivement = n;
                    t.isShowProtection = _.any(t.myAchivement, { configName: "totalCharge" });
                    s = !0;
                    t.hasChanged = !0 } else t.protection.configName = "protectionAmount", t.protection.configValue = !1, t.protection.coments = "", t.protection.configType = "Dashboard" })) : r.isGroup ? u.getSystemConfigByType("GroupMyAchivement").success(function(n) { if (n.length > 0) { s = !0;
                    t.hasChanged = !0; var i = !1;
                    angular.forEach(n, function(n) { n.configName == "protectionAmount" && (t.protection = n, t.protection.configValue = n.configValue.toUpperCase() == "TRUE" ? !0 : !1, i = !0) });
                    i || (t.protection.configName = "protectionAmount", t.protection.configValue = !1, t.protection.coments = "", t.protection.configType = "Dashboard") } t.myAchivement = n }) : u.getSystemConfigByType("Dashboard").success(function(n) { if (n.length > 0) { s = !0;
                    t.hasChanged = !0; var i = !1;
                    angular.forEach(n, function(n) { n.configName == "protectionAmount" && (t.protection = n, t.protection.configValue = n.configValue.toUpperCase() == "TRUE" ? !0 : !1, i = !0) });
                    i || (t.protection.configName = "protectionAmount", t.protection.configValue = !1, t.protection.coments = "", t.protection.configType = "Dashboard") } }) },
        c = function(n, t) { var i = [],
                r; return o.frontSummaryBlockDic && (r = _.pluck(o.frontSummaryBlockDic, "configName"), i = _.filter(n, function(n) { return _.indexOf(r, n.configName) > -1 ? !0 : !1 })), angular.forEach(o.frontSummaryBlockDic, function(n) { var r = _.find(i, { configName: n.configName }),
                    u;
                r ? r && r.configName == "smsCount" && (r.coments = "短信") : (u = n.type == "今日就诊" ? n.type : "今日" + n.type, n.configName == "smsCount" && (u = "短信"), i.push({ configName: n.configName, configType: t, configValue: "false", coments: u })) }), i },
        v = function(n) { var i, r, f, u, e, o; if (t.selectedItem && (i = t.myAchivement, r = _.findIndex(i, { id: t.selectedItem.id }), r > -1)) { if (f = i[r], u = r + n, u < 0 || u >= i.length) return;
                e = i[u];
                o = f.displayOrder;
                f.displayOrder = e.displayOrder;
                e.displayOrder = o;
                t.myAchivement = _.sortBy(i, "displayOrder");
                t.hasChanged = !0 } },
        y = function() { t.hasChanged ? t.isFrontOperator ? u.updateSystemConfigList(t.myAchivement).success(function() { l();
                u.updateSystemConfigList(t.systemConfigs).success(function() { h(t.hasChanged) }) }) : (l(), u.updateSystemConfigList(t.systemConfigs).success(function() { h(t.hasChanged) })) : h(t.hasChanged) },
        h = function(n) { i.close(n) },
        l = function() { t.systemConfigs = [];
            t.protection.configValue = t.protection.configValue ? "true" : "false";
            t.systemConfigs.push(t.protection) },
        p = function() { return r.dashboardType == "Doctor" },
        w = function() { return r.dashboardType == "FrontDesk" };
    (function() { t.protection = {};
        t.hasChanged = !1;
        t.close = h;
        t.save = y;
        t.move = v;
        a() })() }]);
dashboardModule.controller("OverduePatientCtrl", ["$log", "$filter", "$scope", "$modal", "appNav", "constants", "patientSvc", "dashboardSvc", "formatUtil", "shortMessageUtil", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var l = function(n) { u.goToPatient(n.patient.id) },
        c = function() { var n = Ares.today(),
                r = moment(n).add(1, "d").toDate(),
                u = { startTime: moment(n).add(-20, "y").format("YYYY-MM-DD"), endTime: moment(r).format("YYYY-MM-DD"), isOverdue: !0 };
            e.advanceSearchPatients(u).success(function(n) { for (var r = 0; r < n.length; ++r) n[r].sexStr = t("toSexString")(n[r].sex), n[r].imgSrc = t("patientPhoto")(null, n[r]);
                i.overduePatList = n;
                i.hasPatient = n.length > 0 }) },
        a = function(n, t) { h.sendMessage(n, t) },
        v = function() { var n = i.overduePatList ? i.overduePatList.length : 0;
            i.$parent && i.$parent.refreshDashboardBlockHint && i.$parent.refreshDashboardBlockHint(n) };
    (function() { i.refresh = c;
        i.goToPatient = l;
        i.sendMessage = a;
        i.updateCount = v;
        i.hasPatient = !0;
        c() })() }]);
dashboardModule.controller("StockExpirationRemindCtrl", ["$log", "$scope", "$location", "$http", "$timeout", "appNav", "reportSvc", "officeOptionSvc", function(n, t, i, r, u, f, e, o) { "use strict";
    t.expiratingInventoryList = []; var h = function() { t.criteria = { warehouseId: 0, dayOffset: t.dayOffset ? t.dayOffset : 0 };
            s() },
        c = function() { var n = t.expiratingInventoryList ? t.expiratingInventoryList.length : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        s = function() { e.getExpiratingInventoryList(t.criteria).success(function(n) { t.expiratingInventoryList = n;
                t.hasFilteredInventory = n.length > 0 }) };
    (function() { t.query = s;
        t.updateCount = c;
        t.isInventoryValidityWarnEnabled = !0;
        o.getOfficeOption(o.optionKeys.IsInventoryValidityWarnEnabled).then(function(n) { t.isInventoryValidityWarnEnabled = n;
            t.initWareHouseDropdown();
            n && o.getOfficeOption(o.optionKeys.InventoryValidityWarnDayOffset).then(function(n) { t.dayOffset = n;
                h() }) }) })() }]);
dashboardModule.controller("TodayAdminOfficeRevisitListCtrl", ["$log", "$filter", "$q", "$scope", "$timeout", "appNav", "adminOfficeSvc", "formatUtil", "apptUtil", "patientUtil", "patientSvc", "aresDialog", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l, a) { "use strict"; var p = function(n) { f.goToPatient(n.patient.id) },
        v = function() { var n = moment(r.date).format("YYYY-MM-DD");
            e.getRevisits(n, r.currentOfficeId, r.revisitType, r.revisitStatus, a.providerId).success(function(n) { o.formatAdminOfficeRevisits(n, { abbreviation: "officeAbbr", method: "revisitMethodStr", type: "revisitTypeStr", state: "revisitStateStr", recordCreatedTime: "longDateMM" });
                r.adminOfficeRevisits = n;
                r.hasRevisits = n && n.length > 0;
                u(function() { r.noDataMessage = n && n.length > 0 ? "" : "没有找到符合的记录" }, 300);
                y() }) },
        y = function() { var n = [],
                t = [];
            _.each(r.adminOfficeRevisits, function(n) { t.push(n.patientId) });
            c.getPatientsHeadInfo(t).then(function(t) { angular.forEach(r.adminOfficeRevisits, function(i) { var u = w(i),
                        r;
                    u && (r = _.find(t.data, { id: i.patientId }), i.patientHead = r, n.push(i)) });
                r.filteredRevisits = n }) },
        w = function(n) { if (!r.searchText) return !0; return n.nameCode && n.nameCode.indexOf(r.searchText) > -1 || n.mobile && n.mobile.indexOf(r.searchText) > -1 || n.patientName.indexOf(r.searchText) > -1 },
        b = function(n, t) { t = t || "d"; var i = moment(r.date).add(n, t).toDate();
            r.date = i;
            u(function() { v() }, 100) },
        k = function(n) { r.revisitId = n.id;
            r.patientId = n.patientId;
            r.isShowRevisitEditDialog = !0 },
        d = function(n) { l.confirm("提醒", "确定要取消此回访记录？").then(function() { e.cancelRevisit(n.id).success(function() { r.showNotification("取消成功！");
                    v() }).error(function() { r.showErrorNotification("取消失败!") }) }) },
        g = function(n) { return n.state == 0 },
        nt = function(n) { return n.state == 0 };
    (function() { r.goToPatient = p;
        r.loadRevisits = v;
        r.date = Ares.today();
        r.navigate = b;
        r.matchSearch = y;
        r.isInitialized = !1;
        r.updateRevisit = k;
        r.cancelRevisit = d;
        r.canEdit = g;
        r.canCancel = nt;
        r.$watch("date", function() { r.refreshDate() }) })() }]);
dashboardModule.controller("TodayCheckedInPatientCtrl", ["$log", "$scope", "$modal", "$state", "$timeout", "$q", "$filter", "appNav", "constants", "enums", "sessionCache", "patientSvc", "appointmentSvc", "practiceSvc", "officeSvc", "formatUtil", "shortMessageUtil", "apptUtil", "patientUtil", "userOptionSvc", "aresDialog", "gridOptionUtil", "providerSvc", "dataDicSvc", "userSvc", "loginContext", "printUtil", "printTemplateUtil", "officeOptionSvc", "moduleOptionProvider", "aresNotification", "permissionProvider", "systemOptionSvc", "chargeSvc", "yibaoChargePrint", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it, rt, ut, ft, et, ot, st, ht, ct, lt, at, vt) { "use strict"; var ni = null,
        si = [],
        kt = null,
        wt = null,
        dt = c.getCache(c.keys.FrontAppointmentSearchCriteria),
        hi = function() { var n, i;
            wt = { name: "", includeCharged: !1, includeLeft: !1, currentToggleTab: "all", doctorId: undefined, patientId: null };
            n = dt.loadObject();
            _.isEmpty(n) || (_.extend(wt, n), t.date = moment(n.date).format("YYYY-MM-DD"));
            _.isEmpty(n) && t.officeSetting && (i = _.find(t.officeSetting.systemConfigs, { configName: "DefaultIncludeCharged" }), i && (wt.includeCharged = i.configValue.toUpperCase() == "TRUE" ? !0 : !1));
            t.criteria = wt },
        ci = function() { var n = Ares.today(),
                i = moment(n).add(1, "d").toDate(),
                r = new Ares.DateRange(n, i);
            t.dateRange = r },
        gt = function() { var n = [];
            angular.forEach(t.appts, function(i) { var r = li(i); if (r && !t.criteria.includeCharged && (r = i.isCheckedOut != !0), r && !t.criteria.includeLeft && (r = i.isLeft != !0), r) switch (t.criteria.currentToggleTab) {
                    case "all":
                        r = !0; break;
                    case "checkedIn":
                        r = i.isCheckedIn || i.isCheckedOut || i.isCompleted || i.isSeated || i.isLeft; break;
                    case "notCheckedIn":
                        r = !(i.isCheckedIn || i.isCheckedOut || i.isCompleted || i.isSeated || i.isLeft) } r && n.push(i) });
            u(function() { var i = _.filter(t.appts, function(n) { return n.isCheckedIn || n.isCheckedOut || n.isCompleted || n.isSeated || n.isLeft });
                t.checkInApptCont = i ? i.length : 0;
                t.notCheckInApptCont = t.appts ? t.appts.length - t.checkInApptCont : 0;
                t.filteredAppts = n;
                t.allApptCount = t.appts.length;
                t.hasPatient = t.appts ? t.appts.length > 0 : !1;
                t.hasFilteredPatient = t.filteredAppts ? t.filteredAppts.length > 0 : !1 }) },
        li = function(n) { var r = t.criteria ? t.criteria.name : null,
                i, u; return !r || r == "" ? !0 : (i = n.patient, u = i.nameCode && i.nameCode.indexOf(r) > -1 || i.mobile && i.mobile.indexOf(r) > -1 || i.privateId && i.privateId.indexOf(r) > -1 || i.name.indexOf(r) > -1, u) },
        yt = function(n) { b.refreshApptInApptListEx(n, t.appts, gi).then(function(n) { n && (ui(n), ei([n]), n.checkInType && (n.isFirstVisitStr = n.checkInType), n.isFirstVisitStr += " " + ii(n));
                gt() }) },
        ai = function(n) { l.getPatientConsultantId(n.patientId).then(function(i) { k.createAppt(n.patientId, !1, null, i.data).then(function(n) { Ares.isToday(n.startTime) && (yt(n), t.refreshAppts(n.id)) }) });
            window.Ares3 && Ares.sensors.track("NewAppointmentCreate", { OperationType: "新建预约", OperationMode: ut.dashboardRoleType + "今日工作-今日就诊" }) },
        vi = function(n) { b.seatAppt(n).then(function(n) { yt(n);
                t.refreshAppts(n.id);
                pt() }) },
        yi = function(n) { b.completeAppt(n).then(function(n) { yt(n);
                pt();
                t.refreshAppts(n.id) }) },
        pi = function(n) { b.checkOutAppt(n).then(function(n) { n ? (yt(n), t.refreshAppts(n.id)) : g.error("订单状态", "核销失败，请联系e看牙开放平台运营微信号：linkedcarekf，防止核销不成功消费者退款导致无法结算！") }) },
        wi = function(n) { b.leftAppt(n).then(function(n) { yt(n);
                pt() }) },
        bi = function(n) { t.getStatus(n) ? b.checkInApptById(n.id, null, n.patient).then(function(n) { yt(n);
                t.refreshAppts(n.id);
                pt() }) : k.editFollowUpApptById(n.id).then(function(n) { yt(n);
                t.refreshAppts(n.id);
                pt() }) },
        ki = function(n) { b.cancelAppt(n).then(function(n) { yt(n);
                t.refreshAppts(n.id) }) },
        di = function(n) { w.sendMessage(n.patient.id, n.id) },
        uu = function() {},
        gi = function(n) { var i = !1,
                r, t; return n.isPending || n.isCancelled || (r = moment(n.startTime).toDate(), t = ni, t || (t = ti()), i = t.contains(r)), i },
        ti = function() { return t.isLoaded && t.getDateRange ? t.getDateRange() : t.dateRange },
        bt = function() { t.isLoaded && pt() },
        pt = function(n) { var i = moment(t.date).format("YYYY-MM-DD"),
                r = moment(t.date).add(1, "d").format("YYYY-MM-DD"),
                u = { officeId: t.officeId || ut.officeId, startTime: i, endTime: r, isCancelled: !1, isApptTimeRequired: !0, isPrivateIdRequired: !0, department: t.department, doctorId: t.criteria ? t.criteria.doctorId : undefined, patientId: t.criteria ? t.criteria.patientId : null };
            t.criteria && (t.criteria.date = t.date, dt.saveObject(t.criteria));
            a.searchFullAppointments(u).success(function(i) { t.selectedAppts = [];
                ni = ti();
                p.formatAppts(i, ui);
                ei(i);
                i = _.filter(i, function(n) { return n.stateStr != "待定" });
                angular.forEach(i, function(n) { n.checkInType && (n.isFirstVisitStr = n.checkInType);
                    n.isFirstVisitStr += " " + ii(n) });
                k.formatPatientHeadInfo(i).then(function(i) { i && i.length > 0 && (t.totalPatientCount = i[0].totalPatientCount, t.totalPersonTime = i[0].totalPersonTime);
                    t.appts = _.sortBy(i, "apptTimeStr");
                    t.hasPatient = i ? i.length > 0 : !1;
                    t.cachedAppts = [];
                    gt();
                    t.todayApptsData = i;
                    n && n() }) }) },
        ii = function(n) { var t; return (t = n.isCheckedIn && n.appointmentTime && n.appointmentTime.checkInTime ? moment(n.appointmentTime.checkInTime) : moment(n.startTime), t.format("YYYY-MM-DD") == moment(n.recordCreatedTime).format("YYYY-MM-DD")) ? "到" : t > moment(n.recordCreatedTime) ? "约" : void 0 },
        ri = function() { var n = moment(t.date).format("YYYY-MM-DD"),
                i = moment(t.date).add(1, "d").format("YYYY-MM-DD"),
                r = { officeId: t.officeId || ut.officeId, startTime: n, endTime: i, isCancelled: !1, isApptTimeRequired: !0, isPrivateIdRequired: !0 };
            t.criteria && (t.criteria.date = t.date, dt.saveObject(t.criteria)) },
        ui = function(n) { n.apptTimeStr = n.isCheckedIn && n.appointmentTime && n.appointmentTime.checkInTime ? moment(n.appointmentTime.checkInTime).format("HH:mm") : n.startTimeStr ? n.startTimeStr : moment(n.startTime).format("HH:mm") },
        nr = function(n) { t.isLoaded || pt(function() { t.isLoaded = !0 }, n) },
        tr = function() { var n = t.appts ? t.appts.length : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        ir = function() { t.$parent && t.$parent.refreshFollowupBlockHint && t.$parent.refreshFollowupBlockHint() },
        fu = function(n) { b.removeApptFromApptList(n, t.appts);
            b.removeApptFromApptList(n, t.filteredAppts) },
        rr = function(n) { var i = _.filter(t.todayApptsData, function(t) { return t.patient.id == n.patient.id && t.id != n.id && !t.isCheckedIn }),
                r = function(n) { var r = _.find(i, function(t) { return t.id == n });
                    t.checkInAppt(r) };
            b.checkInApptById(n.id, null, n.patient, i, r).then(function(n) { yt(n);
                t.refreshAppts(n.id);
                pt() }) },
        ur = function(n) { b.assignApptConsultantById(n.id).then(function(n) { yt(n);
                t.refreshAppts(n.id) }) },
        fr = function(n) { b.undoCheckInAppt(n).then(function(n) { yt(n);
                t.refreshAppts(n.id) }) },
        er = function(n) { if (n && b.isEnabledChannel(t.channels, n.sourceType) && n.isCheckedOut) { g.error("错误", "第三方渠道预约已经核销，无法回退"); return } b.undo(n).then(function(n) { yt(n);
                t.refreshAppts(n.id);
                pt() }) },
        or = function(n, i) { i = i || "d"; var r = moment(t.date).add(n, i).toDate();
            t.date = r;
            kt && u.cancel(kt);
            kt = u(function() { bt() }, 100) },
        sr = function() { var n = f.defer(); return y.getOfficeSetting().success(function(i) { t.officeSetting = i;
                t.systemConfigs = {}; var r = t.officeSetting.systemConfigs;
                angular.forEach(t.officeSetting.systemConfigs, function(n) { n.configName == "AllowNewCharge" && (t.allowNewCharge = n.configValue.toUpperCase() == "TRUE" ? !0 : !1) });
                n.resolve() }).error(function() { n.resolve() }), n.promise },
        hr = function(n) { if (t.criteria != null) { if (n != undefined && n === t.criteria.currentToggleTab) return;
                n && (t.isResetPage = !0);
                t.criteria.currentToggleTab = n || t.criteria.currentToggleTab;
                gt();
                ri() } },
        cr = function(n) { t.criteria.doctorId = n ? n.id : null;
            bt() },
        lr = function(n) { t.criteria.patientId = n ? n.id : null;
            bt() },
        ar = function(n) { var i = n.patientId;
            v.getNoChargeOrders(i).success(function(r) { if (r && r.length > 0) { var u = _.find(r, function(n) { return n.status === "等待微信付费" ? !0 : !1 }); if (u) { t.showErrorNotification("请先支付或者撤销待付费微信订单！"); return } } o.goToCharge(i, n.id).then(function() { var n = t.DefaultCharge.toLowerCase().replace("charge", "");
                    o.switchState("patientCharge.createSourceOrder", { patientId: i, chargeType: n }) }) }) },
        vr = function(n) { ot.getOfficeOption(ot.optionKeys.IsYibaoCheckInEnabled).then(t => { t ? yr(n.id).then(t => { var i = t ? t.data : {};
                    i && i.id > 0 ? pr(i) : fi(n) }) : fi(n) }) },
        yr = function(n) { var t = f.defer(); return at.getApptYibaoCheckinOrder(n).then(n => { t.resolve(n) }), t.promise },
        fi = function(n) { var u = n.doctorId,
                f = _.filter(t.filteredAppts, function(t) { return t.doctorId == u && n.isLeft == 0 && t.isCompleted == 0 }),
                r = angular.copy(f),
                i;
            r.sort(function(n, t) { return t.startTime === n.startTime ? n.checkInNo - t.checkInNo : t.startTime >= n.startTime ? -1 : 11 });
            i = 0;
            r.forEach(function(t, r) { t.id == n.id && (i = r) });
            n.waitCount = i;
            ot.getOfficeOption(ot.optionKeys.IsSpeechCallScreenEnabled).then(function(i) { var f = st.isSpeechCallScreenEnabled(),
                    r = angular.copy(n),
                    u = !1;
                f && i && (r.checkInNo = 100 + n.checkInNo, u = !0);
                t.refreshTemplate(r, u).then(() => { t.printPage ? ft.printWithIframe(t.printPage) : ht.error("打印模板错误") }) }) },
        pr = function(n) { var t = new vt.YibaoChargePrinter,
                i = { chargeOrderId: n.id, feeType: n.feeType, sourceChargeOrderId: n.sourceChargeOrderId };
            t.setTemplateBaseData(i).setPrintTemplateInfo({ isPrivateTemplate: !0, templateCode: "yibaoCharge" }, "Custom").setOptions({ isNeedBaseData: !0 }).print() },
        wr = function() { br();
            v.getTemplate("checkIn").then(n => { var i = n ? n.data : null; if (i && i.length > 0) t.printTemplate = i[i.length - 1];
                else return et.getTemplateByCode("todayCheckedInTemplate") }).then(n => { n && (t.printTemplate = n) }) },
        br = function() { it.officeDic.load().then(function(n) { t.office = _.find(n, function(n) { return n.id == ut.officeId }) }) },
        kr = function(n) { n && d.setUserOption(nt.keys.todayCheckedInPatientGridOption, n) },
        dr = function() { var n = f.defer(); return d.getUserOption(nt.keys.todayCheckedInPatientGridOption).then(function(i) { t.showColumns = i != null ? i : "^";
                n.resolve(!0) }), n.promise },
        gr = function() { var n = f.defer(); return it.providerDic.load().then(function(i) { t.providers = i;
                n.resolve(!0) }), n.promise },
        nu = function() { var n = f.defer(); return it.userNameDic.load().then(function(i) { t.users = i;
                n.resolve(!0) }), n.promise },
        tu = function() { var n = f.defer(); return it.operatoryDic.load().then(function(i) { t.operatories = i;
                n.resolve(!0) }), n.promise },
        ei = function(n) { angular.forEach(n, function(n) { var u, i, r; if (n.department = n.department, n.patientSourceType = n.patient.sourceType, n.patientCreatedUser = n.patient.recordCreatedUser, n.apptCreatedUser = n.recordCreatedUser, u = _.find(t.operatories, function(t) { return t.id == n.operatoryId }), n.operatoryId = u ? u.description : "", n.apptSourceType = n.sourceType == "marketcenter" ? "网络预约" : n.sourceType ? n.sourceType : "其他", n.patientCreatedUser && (i = _.find(t.users, function(t) { return t.id == n.patientCreatedUser }), n.patientCreatedUser = i ? i.name : ""), n.apptCreatedUser && (i = _.find(t.users, function(t) { return t.id == n.apptCreatedUser }), n.apptCreatedUser = i ? i.name : ""), n.consultantId && (r = _.find(t.providers, function(t) { return t.id == n.consultantId }), n.consultantName = r ? r.name : ""), n.assistantId && (r = _.find(t.providers, function(t) { return t.id == n.assistantId }), n.assistantName = r ? r.name : ""), n.checkInTimeStr = n.isCheckedIn && n.appointmentTime && n.appointmentTime.checkInTime ? moment(n.appointmentTime.checkInTime).format("HH:mm") : "", n.startTime)
                    if (n.endTime) { var f = moment(n.startTime),
                            o = moment(n.endTime),
                            s = o.diff(f, "minutes");
                        n.appointmentTimeStr = f.format("HH:mm") + "-" + o.format("HH:mm") + " " + s + "分钟" } else n.appointmentTimeStr = moment(n.startTime).format("HH:mm");
                else n.appointmentTimeStr = "";
                n.isFirstVisit != undefined && (n.isFirstVisitText = e("toFirstVisit")(n.isFirstVisit));
                n.mobiles && (n.mobileStr = oi(n.mobiles));
                n.telephones && (n.telephoneStr = oi(n.telephones)) }) },
        oi = function(n) { for (var i = [], t = 0; t < n.length; t++) n[t].mobile != "" && i.push(n[t].mobileType + ":" + n[t].mobile); return i },
        iu = function() { var n = f.defer(); return ot.getOfficeOption(ot.optionKeys.IsSpeechCallScreenEnabled).then(function(i) { t.isSpeechCallScreenEnabled = i;
                n.resolve(!0) }), n.promise },
        ru = function() { it.enabledChannelsDic.load().then(function(n) { t.channels = n }) };
    (function() { t.criteria = { patientId: 0 };
        t.department = ut.department;
        t.isLoaded = !1;
        t.refresh = bt;
        t.toggleStateSelection = hr;
        t.query = pt;
        t.createAppt = ai;
        t.checkInAppt = rr;
        t.undoCheckInAppt = fr;
        t.seatAppt = vi;
        t.completeAppt = yi;
        t.checkOutAppt = pi;
        t.leftAppt = wi;
        t.printAppt = vr;
        t.undo = er;
        t.editApptOrEditCheckIn = bi;
        t.cancelAppt = ki;
        t.refreshAppt = yt;
        t.sendMessage = di;
        t.selectedStates = si;
        t.hasPatient = !0;
        t.hasFilteredPatient = !0;
        t.updateCount = tr;
        t.navigate = or;
        t.date = Ares.today();
        t.isInitialize = !0;
        t.consultAppt = ur;
        t.createChargeOrder = ar;
        t.DefaultCharge = "";
        t.saveSearchCriteria = ri;
        t.updateColumnsOption = kr;
        t.loadColumnsOption = dr;
        t.updateFollowupCount = ir;
        t.checkInApptCont = 0;
        t.notCheckInApptCont = 0;
        t.allApptCount = 0;
        t.cachedAppts = [];
        t.printTemplate = null;
        t.checkInIndex = 0;
        t.totalPatientCount = 0;
        t.totalPersonTime = 0;
        t.channels = [];
        t.isTenantSpeechCallScreenEnabled = st.isSpeechCallScreenEnabled();
        t.doctorChange = cr;
        t.patientChange = lr;
        v.getSystemConfigByName("DefaultCharge").success(function(n) { t.DefaultCharge = n.configValue });
        ru();
        ci();
        iu();
        sr().then(function() { hi();
            nu().then(function() { gr().then(function() { tu().then(function() { nr(!0) }) }) }) });
        wr();
        t.$watch("date", function() { t.refreshDate() });
        t.$on("patientCheckIn", function() { pt() }) })() }]);
dashboardModule.controller("TodayFirstVisitPatientListCtrl", ["$log", "$filter", "$q", "$scope", "$timeout", "appNav", "appointmentSvc", "formatUtil", "apptUtil", "patientUtil", "patientSvc", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; var v = function(n) { f.goToPatient(n.patient.id) },
        l = function() { var n = moment(r.date).format("YYYY-MM-DD");
            e.searchAdminOfficeAppointments(n, r.currentOfficeId, r.appointmentType, r.selectedCheckInState).success(function(n) { o.formatAdminOfficePatientAppts(n, { birth: "ageStr", abbreviation: "officeAbbr", recordCreatedTime: "longDateMM", appointmentTime: "ShortTimeString", checkInTime: "ShortTimeString", sex: "sexStr" });
                r.adminOfficeAppointments = n;
                r.hasAppointments = n && n.length > 0;
                u(function() { r.noDataMessage = n && n.length > 0 ? "" : "没有找到符合的记录" }, 300);
                a() }) },
        a = function() { var n = [],
                t = [];
            _.each(r.adminOfficeAppointments, function(n) { t.push(n.patientId) });
            c.getPatientsHeadInfo(t).then(function(t) { angular.forEach(r.adminOfficeAppointments, function(i) { var u = y(i),
                        r;
                    u && (r = _.find(t.data, { id: i.patientId }), i.patientHead = r, n.push(i)) });
                r.filteredAppts = n }) },
        y = function(n) { if (!r.searchText) return !0; return n.nameCode && n.nameCode.indexOf(r.searchText) > -1 || n.mobile && n.mobile.indexOf(r.searchText) > -1 || n.patientName.indexOf(r.searchText) > -1 },
        p = function(n, t) { t = t || "d"; var i = moment(r.date).add(n, t).toDate();
            r.date = i;
            u(function() { l() }, 100) },
        w = function(n) { h.editFollowUpApptById(n.id).then(function() { l() }) },
        b = function(n) { n && (n.patient = { name: n.patientName }, n.startTime = n.appointmentTime);
            s.cancelAppt(n).then(function() { l() }) };
    (function() { r.goToPatient = v;
        r.loadAppointments = l;
        r.date = Ares.today();
        r.navigate = p;
        r.matchSearch = a;
        r.isInitialized = !1;
        r.updateAppt = w;
        r.cancelAppt = b;
        r.$watch("date", function() { r.refreshDate() }) })() }]);
dashboardModule.controller("TodayWorkSettingCtrl", ["$log", "$scope", "$modalInstance", "practiceSvc", "dashboardConfig", "loginContext", function(n, t, i, r, u, f) { "use strict"; var o = function() { r.getSystemConfigByName("AllowStatement").success(function(n) { n && (t.allowStatement = n.configValue.toUpperCase() == "TRUE" ? !0 : !1);
                r.getSystemConfigByType("Dashboards").success(function(n) { var i; if (n.length > 0) { for (i = 0; i < n.length; i++) n[i].configValue = n[i].configValue.toUpperCase() == "TRUE" ? !0 : !1, (n[i].displayOrder == null || n[i].displayOrder != i) && (n[i].displayOrder = i); for (i = 0; i < n.length; i++) { if (n[i].configName == "todayAccount" && !t.allowStatement) { n.splice(i, 1); break } if (n[i].coments == "网络预约" && f.isProfessional) { n.splice(i, 1); break } } } s(n);
                    t.dashboard = n }) }) },
        s = function(n) { var r, t, e, f, i; if (u)
                for (r = 0; r < u.length; r++)
                    for (t = n.length - 1; t >= 0; t--) e = n[t], f = u[r], e.configName == f.Name && f.Value.toUpperCase() == "FALSE" && n.splice(t, 1);
            else
                for (i = n.length - 1; i >= 0; i--) n[i].configName == "todayRevisit" && n.splice(i, 1) },
        h = function(n) { var i, r, f, u, e, o; if (t.selectedItem && (i = t.dashboard, r = _.findIndex(i, { id: t.selectedItem.id }), r > -1)) { if (f = i[r], u = r + n, u < 0 || u >= i.length) return;
                e = i[u];
                o = f.displayOrder;
                f.displayOrder = e.displayOrder;
                e.displayOrder = o;
                t.dashboard = _.sortBy(i, "displayOrder");
                t.hasChanged = !0 } },
        c = function() { t.hasChanged ? r.updateSystemConfigList(t.dashboard).success(function() { e(t.hasChanged) }) : e(t.hasChanged) },
        e = function(n) { i.close(n) };
    (function() { t.protection = {};
        t.hasChanged = !1;
        t.close = e;
        t.save = c;
        t.move = h;
        o() })() }]);
dashboardModule.controller("UnchargedPatientCtrl", ["$log", "$scope", "$timeout", "$q", "$modal", "$filter", "appNav", "constants", "appointmentSvc", "dashboardSvc", "formatUtil", "practiceSvc", "chargeUtil", "paySvc", "chargeSvc", "officeSvc", "eventAggregator", "aresNotification", "sessionCache", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k) { "use strict"; var g = k.getCache(k.keys.DashboardUnchargedPatientSearchCriteria),
        it = function() { var n = Ares.today(),
                i = moment(n).add(-1, "week").toDate();
            t.timeSpan = { startDate: i, endDate: n } },
        rt = function() { var n, i;
            t.unchargeOrders ? (n = t.unchargeOrders.todayCount, i = t.unchargeOrders.allCount) : (n = 0, i = 0);
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(i, n) },
        ut = function(n) { n != null && (t.date && (n.date = moment(t.date).format("YYYY-MM-DD")), n.startDate && (n.startDate = n.startDate.format("YYYY-MM-DD")), n.endDate && (n.endDate = n.endDate.format("YYYY-MM-DD")), g.saveObject(n)) },
        ft = function() { var n = r.defer(),
                i = g.loadObject(); return i && (_.extend(t.criteria, i), t.criteria && t.criteria.date && (t.date = t.criteria.date), t.criteria && t.criteria.startDate && (t.timeSpan.startDate = t.criteria.startDate), t.criteria && t.criteria.endDate && (t.timeSpan.endDate = t.criteria.endDate)), n.resolve(t.criteria), n.promise },
        d = function(n) { var h = new Date,
                r, u, e = $("#unchargedTodayInput").val(),
                o, s;
            e == "自定义" ? (r = moment(t.timeSpan.startDate), u = moment(t.timeSpan.endDate).add(1, "d")) : $("#unchargedTodayInput").val() == "week" ? (r = moment(Ares.today()).startOf("week"), u = moment(Ares.today()).add(1, "d")) : $("#unchargedTodayInput").val() == "month" ? (r = moment(Ares.today()).startOf("month"), u = moment(Ares.today()).add(1, "d")) : _.isEmpty(n) ? (r = moment(Ares.today()).add(-$("#unchargedTodayInput").val(), "d"), u = moment(Ares.today()).add(1, "d")) : (e = n.range, r = moment(n.startDate), u = moment(n.endDate).add(1, "d"));
            e = e ? e : t.criteria.range;
            o = { range: e, startDate: r, endDate: moment(u).add(-1, "d") };
            ut(o);
            s = f("toSexString");
            y.getNoBillChargeOrdersByRange(r, u).success(function(n) { if (n)
                    if (t.unchargeOrders = n, n.items && n.items.length > 0) { for (var r = 0; r < n.items.length; ++r) n.items[r].sexStr = s(n.items[r].sex), n.items[r].startTime && (n.items[r].startTime = moment(n.items[r].startTime).format("YYYY-MM-DD HH:mm"));
                        i(function() { t.unchargeAppts = n.items;
                            t.hasPatient = n.items.length > 0 }) } else i(function() { t.unchargeAppts = [] }) }) },
        nt = function(n) { return !n || !t.systemConfigs.allowAliPay || t.systemConfigs.allowAliPay == !1 ? !1 : n.payType == "支付宝" && n.actualPrice1 > .001 ? !0 : n.payType2 == "支付宝" && n.actualPrice2 > .001 ? !0 : n.payType3 == "支付宝" && n.actualPrice3 > .001 ? !0 : !1 },
        tt = function(n) { var i = u.open({ animation: !0, backdrop: "static", template: "<qrcode-dialog><\/qrcode-dialog>", controller: "QrcodeDialogCtrl", size: "sm", resolve: { host: function() { return { qrCode: n.qrCode, outTradeNo: n.outTradeNo, updateStatus: !0 } } } });
            i.result.then(function(n) { n.msg == "已收费" ? (t.showNotification("支付宝付款成功！"), d()) : (n.msg == "超时关闭" || n.msg == "订单失效") && (t.showErrorNotification("订单超时关闭！"), e.switchState("patientCharge.historyRecords", { patientId: t.patientId })) }) },
        et = function(n) { var i = u.open({ animation: !0, backdrop: "static", template: "<alipay-dialog><\/alipay-dialog>", controller: "AlipayDialogCtrl", size: "sm", resolve: { host: function() { return { chargeOrder: n, dialogMode: "update" } } } });
            i.result.then(function() { result.msg == "已收费" ? (t.listPatientChargeOrders(), t.initPatientTotalPrice(), t.showNotification("支付宝付款成功！")) : (result.msg == "超时关闭" || result.msg == "订单失效") && (t.listPatientChargeOrders(), t.initPatientTotalPrice(), t.showNotification("订单状态更新！")) }) },
        ot = function() { return t.currentChargeOrder.payType == "微信支付" || t.currentChargeOrder.payType2 == "微信支付" || t.currentChargeOrder.payType3 == "微信支付" ? "微信支付" : t.currentChargeOrder.payType == "支付宝" || t.currentChargeOrder.payType2 == "支付宝" || t.currentChargeOrder.payType3 == "支付宝" ? "支付宝" : "" },
        st = function() { var n = r.defer(); return v.checkPay(ot(), t.payOrder.payOrderNo).success(function(t) { t && n.resolve({ result: t }) }), n.promise },
        ht = function(n) { var i = { queryFunc: st, interval: 5e3, delay: 1e4, maxCount: 20 },
                r = u.open({ animation: !0, backdrop: "static", template: "<qrcode-dialog><\/qrcode-dialog>", controller: "QrcodeDialogCtrl", size: "sm", resolve: { host: function() { return { qrCode: n.payUrl, outTradeNo: n.payOrderNo, queryOption: i } } } });
            r.result.then(function(n) { n && (t.showNotification("微信付款成功！"), d()) }) },
        pt = function() { return !t.currentChargeOrder || !t.systemConfigs.allowWeixinPay || t.systemConfigs.allowWeixinPay == !1 ? !1 : t.currentChargeOrder.payType == "微信支付" && t.currentChargeOrder.actualPrice1 > .001 ? (t.currentChargeOrder.isAliPayOrder = !0, !0) : t.currentChargeOrder.payType2 == "微信支付" && t.currentChargeOrder.actualPrice2 > .001 ? (t.currentChargeOrder.isAliPayOrder = !0, !0) : t.currentChargeOrder.payType3 == "微信支付" && t.currentChargeOrder.actualPrice3 > .001 ? (t.currentChargeOrder.isAliPayOrder = !0, !0) : !1 },
        ct = function(n) { y.get(n.chargeOrderId).success(function(n) { var t = u.open({ animation: !0, backdrop: "static", template: "<new-patient-charge-overdue-view><\/new-patient-charge-overdue-view>", controller: "NewPatientChargeOverdueCtrl", size: "md", resolve: { host: function() { return { patientId: n.patientId, action: "payPrompt", chargeOrder: n } } } });
                t.result.then(function() { d() }) }) },
        lt = function(n) { y.getNoBillChargeOrders(n.patientId).success(function(i) { var r, f, e; if (i && i.length > 0)
                    for (r = 0; r < i.length; r++)
                        if (i[r].id == n.chargeOrderId)
                            if (i[r].status === "等待支付宝付费") nt(i[r]) && y.billByAliPayQrcode(i[r]).success(function(n) { if (n.id == 0) { t.showErrorNotification("订单信息错误！"); return } n.qrCode == "" ? et(n) : tt(n) }).error(function(n) { n.name === "NoEnoughGiftException" ? t.showErrorNotification("回馈物品剩余次数不足") : n.name === "AliPayOrderPreCreateException" ? t.showErrorNotification("无法创建支付宝订单") : t.showErrorNotification("收费失败") });
                            else { if (f = _.find(i, function(n) { return n.status === "等待支付宝付费" ? !0 : !1 }), f) { t.showErrorNotification("请先支付或者撤销待付费支付宝订单！"); return } e = u.open({ animation: !0, backdrop: "static", template: "<charge-confirm-view><\/charge-confirm-view>", controller: "ChargeConfirmCtrl", windowClass: "large-dialog", size: "md", resolve: { host: function() { return { patientId: n.patientId, chargeId: n.chargeOrderId, apptId: n.appointId } } } });
                                e.result.then(function() { d() }) } }) },
        at = function(n, i) { y.get(n.chargeOrderId).success(function(r) { var f, e; if (t.currentChargeOrder = r, r.status === "等待支付宝付费") nt(r) && y.billByAliPayQrcode(r).success(function(n) { tt(n) }).error(function(n) { n.name === "NoEnoughGiftException" ? t.showErrorNotification("回馈物品剩余次数不足") : n.name === "AliPayOrderPreCreateException" ? t.showErrorNotification("无法创建支付宝订单") : t.showErrorNotification("收费失败") });
                else if (r.status == "等待微信付费") y.continuePay(r.id).success(function(n) { t.payOrder = n;
                    ht(n) }).error(function(n) { n.name == "AresBusinessException" && (t.showNotification("订单已超时关闭！"), d()) });
                else { if (f = _.find(i, function(n) { return n.chargeOrderStatus === "等待支付宝付费" ? !0 : !1 }), f) { t.showErrorNotification("请先支付或者撤销待付费支付宝订单！"); return } r.feeType == 2 || (r.feeType == 5 ? a.batchRepayDialogView(n.patientId, n.chargeOrderId, "prompt").then(function() { d() }) : (e = u.open({ animation: !0, backdrop: "static", template: "<new-charge-confirm-view><\/new-charge-confirm-view>", controller: "NewChargeConfirmCtrl", windowClass: "large-dialog", size: "md", resolve: { host: function() { return { patientId: n.patientId, chargeId: n.chargeOrderId, apptId: n.appointId } } } }), e.result.then(function() { d() }))) } }) },
        vt = function() { p.getOfficeSetting().success(function(n) { t.officeSetting = n;
                t.systemConfigs = {}; var i = t.officeSetting.systemConfigs;
                angular.forEach(t.officeSetting.systemConfigs, function(n) { n.configName == "AllowAliPay" ? t.systemConfigs.allowAliPay = n.configValue.toUpperCase() == "TRUE" ? !0 : !1 : n.configName == "AllowWeixinPay" && (t.systemConfigs.allowWeixinPay = n.configValue.toUpperCase() == "TRUE" ? !0 : !1);
                    n.configName == "AllowNewCharge" && (t.allowNewCharge = n.configValue.toUpperCase() == "TRUE" ? !0 : !1) }) }) },
        yt = function() { w.subscribe(t, w.events.ChargeOrderCreated, d) };
    (function() { t.criteria = { range: 0 };
        t.refresh = d;
        t.updateCount = rt;
        t.hasPatient = !0;
        t.showChargeConfirm = lt;
        t.showNewChargeConfirm = at;
        t.showPromptChargeConfirm = ct;
        t.isShowOld = !1;
        it();
        vt();
        ft().then(function(n) { d(n) });
        yt() })() }]);
dashboardModule.controller("CustomerServiceDashboardConsultQuantityCtrl", ["$log", "$scope", "$q", "$filter", "dashboardSvc", "loginContext", "dataDicSvc", function(n, t, i, r, u, f, e) { "use strict"; var o = function(n) { var r = i.defer(); return e.systemItemDic.loadActive({ itemType: "跟进类型" }).then(function(i) { u.getConsultQuantityReport(n).success(function(n) { var u = t.currentDistricts && !t.isByIntentionDesc ? t.currentDistricts : i;
                    s(u, n);
                    t.consultQuantityList = n;
                    r.resolve(t.consultQuantityList) }) }), r.promise },
        s = function(n, i) { var r, f, u; for (t.intentionsColumns = [{ field: "visitDateStr", title: "日期", width: "160px", groupFooterTemplate: "小计", footerTemplate: "总计" }, { field: "itemName", title: "咨询项目", width: "120px" }, { field: "onlineConsultantName", title: "网电咨询师", width: "150px" }, { field: "revisitCount", title: "回访总量", width: "80px", aggregates: ["sum"], footerTemplate: "#= sum #", groupFooterTemplate: "#= sum #" }, { field: "apptCount", title: "到店患者量", width: "150px", aggregates: ["sum"], groupFooterTemplate: "#= sum #", footerTemplate: "#= sum #" }], t.aggregate = [], !t.currentDistricts || t.isByIntentionDesc || _.any(t.currentDistricts, function(n) { return n.areaName == "其他" }) || n.push({ areaName: "其他" }), r = 1, angular.forEach(n, function(n) { n.index = "p" + r;
                    t.intentionsColumns.push({ field: "p" + r, title: n.itemName ? n.itemName : n.areaName, width: "80px", aggregates: ["sum"], groupFooterTemplate: "#= sum #", footerTemplate: "#= sum #" });
                    r++ }), angular.forEach(i, function(t) { t.visitDateStr = moment(t.visitDate).format("YYYY-MM-DD");
                    h(t, n) }), f = [], u = 0; u < t.intentionsColumns.length; u++) f.push({ field: t.intentionsColumns[u].field, aggregate: "sum" });
            t.aggregate = f },
        h = function(n, t) { n.details && n.details.length > 0 ? angular.forEach(t, function(t) { var i = _.find(n.details, function(n) { return t.itemName == n.intentionDesc || t.areaName == n.intentionDesc });
                n[t.index] = i ? i.count : 0 }) : angular.forEach(t, function(t) { n[t.index] = 0 }) };
    (function() { t.search = o })() }]);
dashboardModule.controller("CustomerServiceDashboardFrontCtrl", ["$log", function() { "use strict";
    (function() {})() }]);
dashboardModule.controller("CustomerServiceDashboardMyPerformanceCtrl", ["$log", "$scope", "$q", "$filter", "dashboardSvc", "loginContext", function(n, t) { "use strict";
    (function() { t.patientIsDealtSource = [{ itemName: "全部", value: "" }, { itemName: "已成交", value: !0 }, { itemName: "未成交", value: !1 }];
        t.visitTypeSource = [{ itemName: "全部", value: "" }, { itemName: "首次到店", value: "once" }, { itemName: "二次到店", value: "twice" }, { itemName: "再次消费", value: "more" }] })() }]);
dashboardModule.controller("CustomerServiceDashboardPendingApptCtrl", ["$log", "$scope", "$modal", "$rootScope", "$q", "$timeout", "$filter", "dashboardSvc", "formatUtil", "apptUtil", "patientUtil", "sessionCache", "loginContext", "providerSvc", "multiOfficeDataDic", "appointmentSvc", "aresNotification", "aresModalShelf", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) { "use strict"; var tt = l.getCache(l.keys.ApptPendingListSearchCriteria),
        k = null,
        it = { daysAfterToday: 1, doctorId: -1, toDate: Ares.tomorrow() },
        rt = { startTime: "date", recordCreatedTime: "dateTime" },
        g = function() { var n = u.defer(),
                i = t.getCheckInType(),
                f = { userId: t.selectedUserId, startDate: t.timeSpan.startDate, endDate: moment(t.timeSpan.endDate).add(1, "days").format("YYYY-MM-DD"), level: r.level, keyWord: t.keyWord, apptStateType: t.apptState, officeIds: a.isGroup ? t.selectedIdsStr : a.officeId, transactionCodeIds: t.transactionCodeIds || "", pageIndex: t.searchCriteria ? t.searchCriteria.pageIndex : 1, pageSize: t.searchCriteria ? t.searchCriteria.pageSize : 10, isFirstVisit: t.isFirstVisit == -1 ? null : t.isFirstVisit == "1" ? !0 : !1, checkInType: i == "全部就诊类型" ? null : i, isVisited: t.isVisited == -1 ? null : t.isVisited == "1" ? !0 : !1, privateTag: t.tagStr, isGroup: a.isGroup }; return t.searchCriteria = f, o.getOnlineConsultAppts(f).success(function(i) { t.pageData = i;
                s.formatAppts(i.items, rt);
                angular.forEach(i.items, function(n) { n.tagStr && (n.tagStr = n.tagStr.substring(0, n.tagStr.length - 1), n.tagStr = n.tagStr.substring(1));
                    n.recordCreatedTimeStr = e("toDateTimeString")(n.recordCreatedTime);
                    n.startTimeStr = e("toDateTimeString")(n.startTime);
                    n.notes = n.notes == null ? "" : n.notes });
                n.resolve(t.pageData) }), n.promise },
        ut = function() { var n = moment().format("YYYY-MM-DD");
            t.timeSpan = { startDate: n, endDate: n } },
        ft = function() { var n = u.defer(),
                i = tt.loadObject(); return i && (_.extend(t.criteria, i), t.criteria.date && (t.date = t.criteria.date)), n.resolve(!0), n.promise },
        et = function(n, i) { p.getAppointment(n.id).success(function(n) { var u;
                n.isPending = !1; var f = moment(n.startTime).toDate(),
                    e = h.getMinutes(n),
                    r = h.getDefaultApptTime(e);
                r.startTime.setDatePart(f);
                r.endTime.setDatePart(f);
                u = Ares.today();
                r.startTime < u && (r.startTime.setDatePart(u), r.endTime.setDatePart(u));
                n.startTime = r.startTime;
                n.endTime = r.endTime;
                c.editFollowUpAppt(n).then(function(n) { n.onlyPatientChanged ? nt(n, t.pendingAppts) : d(n);
                    i(n) }) }) },
        ot = function(t, i) { t.isPending ? h.deletePendingAppt(t).then(function(n) { d(n);
                i(n) }) : n.error("Only pending appt can be deleted.") },
        d = function(n) { h.removeApptFromApptList(n, t.pendingAppts) },
        nt = function(n) { h.refreshApptInApptList(n, t.pendingAppts) },
        st = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        ht = function(n, i) { i = i || "d"; var r = moment(t.date).add(n, i).toDate();
            t.date = r;
            k && f.cancel(k);
            k = f(function() { g() }, 100) },
        ct = function() { var n = angular.copy(t.transactionItems),
                r;
            n || (n = []);
            r = i.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "transactioncode", list: n, officeId: t.selectedOfficeId } } } });
            r.result.then(function(n) { if (n) { t.transactionItems = n.obj; var i = _.pluck(n.obj, "id");
                    i ? (t.transactionCodeIds = i.join(), t.transactionCodeNames = _.pluck(n.obj, "itemName").join()) : (t.transactionCodeIds = "", t.transactionCodeNames = "") } }) },
        lt = function() { var n = u.defer(),
                i = t.isGroup ? t.selectedOfficeId : a.officeId; return i > 0 ? y.loadDic(i, "currentOfficeWorkProviderDic").then(function(t) { t = _.filter(t, function(n) { return n.userID > 0 });
                t = c.filterProviderByPatientPermissionLevel(t);
                n.resolve(t) }) : n.resolve([]), n.promise },
        at = function(n) { p.getAppointment(n).success(function(n) { h.editGroupOfficeFullAppt(n).then(function(n) { n && (w.success("修改成功"), t.refreshGrid()) }) }) },
        vt = function(n) { var i = !0,
                r;
            (n.isCheckedIn || n.isConfirmed) && (i = !1);
            r = b.open({ title: "新增回访", template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return { patientId: n.patientId, isRevisitTask: i } } } });
            r.result.then(function() { t.refreshGrid() }) };
    (function() { ut();
        t.isGroup = a.isGroup;
        t.editAppt = at;
        t.createRevisit = vt;
        t.department = a.department;
        t.criteria = it;
        t.search = g;
        t.removeAppt = d;
        t.refreshAppt = nt;
        t.rebookAppt = et;
        t.deleteAppt = ot;
        t.updateCount = st;
        t.date = Ares.tomorrow();
        t.navigate = ht;
        t.isInitialize = !0;
        t.getCurrentOfficeWorkProviders = lt;
        t.apptState = 0;
        t.keyWord = null;
        t.tagStr = null;
        t.selectedUserId = 0;
        t.openTransactionItemsDialog = ct;
        t.isFirstVisit = -1;
        t.checkInType = "全部就诊类型";
        t.isVisited = -1;
        ft() })() }]);
dashboardModule.controller("CustomerServiceDashboardReportv2Ctrl", ["$log", function() { "use strict";
    (function() {})() }]);
dashboardModule.controller("CustomerServiceDashboardRevisitPlanCtrl", ["$log", "$scope", "$q", "$filter", "dashboardSvc", "loginContext", function(n, t, i, r, u, f) { "use strict"; var e = function(n) { var u = i.defer(),
                r = t.revisitState,
                e = { startDate: t.startDate, endDate: t.endDate, level: t.level, providerId: t.providerId, pageSize: t.pageSize, pageIndex: n ? 1 : t.pageIndex, revisitTimes: "", transactionId: t.transactionId ? t.transactionId : -1, visitorId: t.visitorId ? t.visitorId : -1, revisitType: t.revisitType ? t.revisitType : null, state: r || r == 0 ? r : -1, isGroup: f.isGroup }; return u.resolve(e), u.promise },
        o = function(n) { var r = i.defer(); return e(n).then(function(n) { u.getOnlineConsultRevisitsReport(n).success(function(n) { t.totalRevisitCnt = n.totalRevisitCnt;
                    t.doneRevisitCnt = n.doneRevisitCnt;
                    t.noneRevisitCnt = n.noneRevisitCnt;
                    t.effectiveRevisitCnt = n.effectiveRevisitCnt;
                    t.noEffectiveRevisitCnt = n.noEffectiveRevisitCnt });
                u.getOnlineConsultRevisits(n).success(function(n) { s(n);
                    t.pageData = n;
                    r.resolve(t.pageData) }) }), r.promise },
        s = function(n) { _.each(n.items, function(n) { n.state = r("toRevisitStateStr")(n.state) }) },
        h = function() { var n = t.revisitState,
                i = { startDate: t.startDate, endDate: t.endDate, level: t.level, providerId: t.providerId, transactionId: t.transactionId ? t.transactionId : -1, visitorId: t.visitorId ? t.visitorId : -1, revisitType: t.revisitType ? t.revisitType : null, state: n || n == 0 ? n : -1, isGroup: f.isGroup };
            u.getOnlineConsultRevisitTimes(i).success(function(n) { c(n) }) },
        c = function(n) { var i = [];
            _.each(n, function(n) { var t = moment(n).format("YYYY-MM-DD");
                i.push(t) });
            t.revisitsDays = i };
    (function() { t.pageSize = 20;
        t.pageIndex = 1;
        t.startDate = "";
        t.endDate = "";
        t.providerId = f.providerId;
        t.refreshRevisitPlan = o;
        t.getOnlineConsultRevisitTimes = h })() }]);
dashboardModule.controller("CustomerServiceDashboardWorkbenchCtrl", ["$log", "$scope", "$modal", "$q", "$state", "$filter", "aresNotification", "dashboardSvc", "patientSvc", "loginContext", "moduleOptionProvider", "multiOfficeDataDic", "gridOptionUtil", "providerSvc", "userSvc", "dataDicSvc", "officeSvc", "officeSelectorUtil", "$timeout", "localCache", "patientUtil", "enums", "practiceSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g) { "use strict"; var ft = function() { var n = r.defer(); return t.patientSexual = [{ itemName: "未知", value: "0" }, { itemName: "男", value: "1" }, { itemName: "女", value: "2" }], n.resolve(!0), n.promise },
        et = function() { var n = r.defer(); return t.hasCheckedInData = [{ name: "是", id: 1 }, { name: "否", id: 0 }], n.resolve(!0), n.promise },
        ot = function() { var n = r.defer(); return s.getPatientSourceTypesByOffice(h.officeId).success(function(i) { t.sourceTypeData = i;
                n.resolve(!0); var r = t.sourceTypeData.filter(function(n) { return n.level === 1 }).map(function(n) { return { itemName: n.sourceName } });
                r.unshift({ itemName: "全部" });
                t.sourceTypeOneData = r }), n.promise },
        st = function() { var n = r.defer(); return h.isGroup ? v.getGroupProvidersByJob("医生").success(function(i) { t.doctorData = i;
                l.loadDic(h.officeId, "membershipTypeDic").then(function(i) { t.membershipTypeData = i;
                    n.resolve(!0) }) }) : p.doctorDic.loadActive().then(function(i) { t.doctorData = i;
                l.loadDic(h.officeId, "membershipTypeDic").then(function(i) { t.membershipTypeData = i;
                    n.resolve(!0) }) }), n.promise },
        ht = function() { var n = r.defer(); return h.isGroup ? v.getGroupProvidersByJob("网电营销").success(function(i) { t.networkConsultantData = g.filterProviderByPatientPermissionLevel(i);
                n.resolve(!0) }) : p.webPhoneConsultantDic.loadActive().then(function(i) { t.networkConsultantData = g.filterProviderByPatientPermissionLevel(i);
                n.resolve(!0) }), n.promise },
        ct = function() { var n = r.defer(); return h.isGroup ? v.getGroupProvidersByJob("咨询师").success(function(i) { i.unshift({ name: "未指定咨询师", id: "-999" });
                t.consultantData = i;
                n.resolve(!0) }) : p.consultantDic.loadActive().then(function(i) { i.unshift({ name: "未指定咨询师", id: "-999" });
                t.consultantData = i;
                n.resolve(!0) }), n.promise },
        lt = function() { var n = r.defer(); return t.isGroup ? y.getAllUserNames().success(function(i) { t.users = _.filter(i, function(n) { return n.isInactive == 0 });
                n.resolve(!0) }) : p.officeUserNameDic.loadActive().then(function(i) { t.users = i;
                n.resolve(!0) }), n.promise },
        at = function() { var n = r.defer(); return a.loadColumnsOption(t.gridOptionKey).then(function(i) { t.showColumns = i; var u = d.getCache(d.keys.CustomerServiceDashboardWorkbenchCustomColumn),
                    r = u.loadValue();
                t.isDefaultCustom = r === null ? !0 : t.showColumns && t.showColumns.length > 0 && r === "true";
                n.resolve(!0) }), n.promise },
        vt = function() { var n = r.defer(); return w.getSelfAndChildOfficesByGroupId(h.officeId, !0).success(function(i) { t.officeTreeData = b.setId(i);
                n.resolve(!0) }), n.promise },
        yt = function() { var n = r.defer(); return r.all([ft(), et(), ot(), st(), ct(), ht(), lt(), vt(), at()]).then(function() { n.resolve(!0) }), n.promise },
        pt = function(n) { var i = r.defer(); return query(n).then(function() { i.resolve(t.patientList) }), i.promise },
        wt = function() { var n = r.defer(),
                i = it(),
                u = { startDate: i.startDate, endDate: i.endDate, level: t.level, providerId: t.providerId, isGroup: h.isGroup }; return o.getOnlineConsultSum(u).then(function(i) { t.onlineConsultSumMto = i.data;
                n.resolve(!0) }), n.promise },
        it = function() { var n = moment(Ares.today()).format("YYYY-MM-DD"),
                t = moment(Ares.today()).add(1, "days").format("YYYY-MM-DD"); return { startDate: n, endDate: t } },
        nt = function(n, i, r, u) { var e = i.split("."),
                f; if (e.length === 2) { if (!r) throw "criteriaProperty needed";
                f = t.searchCriteriaModel[e[0]][e[1]] } else r = r || e[0], f = t.searchCriteriaModel[e[0]];
            u && f === u || f !== null && f !== undefined && f !== "" && (n[r] = f) },
        rt = function() { var i = it(),
                r = [],
                u, n; return t.officeTreeInstance && (u = t.officeTreeInstance.getCheckedData(), r = _.pluck(u, "id")), n = { startDate: i.startDate, endDate: i.endDate, level: t.level, officeIds: h.isGroup ? r.join(",") : h.officeId, providerId: t.providerId, pageSize: t.pageSize, pageIndex: t.pageIndex, selectType: t.selectType, isGroup: h.isGroup }, nt(n, "patientSearchText"), nt(n, "onlineConsultantId"), nt(n, "createdTime.startDate", "startCreatedTime"), nt(n, "createdTime.endDate", "endCreatedTime"), nt(n, "firstVisit.startDate", "startFirstVisit"), nt(n, "firstVisit.endDate", "endFirstVisit"), nt(n, "lastVisit.startDate", "startLastVisit"), nt(n, "lastVisit.endDate", "endLastVisit"), nt(n, "birthday.startDate", "startBirthday"), nt(n, "birthday.endDate", "endBirthday"), nt(n, "sex"), nt(n, "startAge"), nt(n, "endAge"), nt(n, "isBindWeixin", "isBindWeixin", "all"), nt(n, "createdUser"), nt(n, "membershipName"), nt(n, "doctorId"), nt(n, "lastDoctorId"), nt(n, "consultantId"), nt(n, "sourceTypeOne", "sourceTypeLevel1", "全部"), n.sourceTypeLevel1 && nt(n, "sourceTypeTwo", "patientSourceTypes", "全部"), n.sourceTypeLevel1 && n.patientSourceTypes && nt(n, "sourceTypeThree", "refereeName", "全部"), nt(n, "hasCheckedIn", "hasCheckedIn", "all"), n },
        tt = function() { var n = r.defer(); return k(function() { var i = rt();
                o.getOnlineConsultPatientsNew(i).then(function(i) { var r = i.data,
                        u;
                    angular.forEach(r.items, function(n) { n.age = f("toAgeMonthString")(n.birth, n) });
                    t.patientList = r;
                    t.pageIndex = r.pageIndex;
                    t.pageSize = r.pageSize;
                    u = new kendo.data.DataSource({ data: r.items });
                    t.gridInstance.setDataSource(u);
                    n.resolve(!0) }) }), n.promise },
        bt = function(n) {
            (n.keyCode === 13 || n.key === "Enter") && tt() },
        kt = function() { ut();
            tt() },
        ut = function() { t.searchCriteriaModel = { createdTime: { startDate: "", endDate: "" }, birthday: { startDate: "", endDate: "" }, firstVisit: { startDate: "", endDate: "" }, lastVisit: { startDate: "", endDate: "" }, isBindWeixin: "all", hasCheckedIn: "all", sourceTypeOne: "全部", sourceTypeTwo: "全部", sourceTypeThree: "全部", patientSearchText: "", sex: "", startAge: "", endAge: "", officeIds: [], createdUser: null, membershipName: "", doctorId: "", lastDoctorId: "", consultantId: "" } },
        dt = function() { t.uiState.isAdvancedSearchOpen = !t.uiState.isAdvancedSearchOpen;
            k(t.setGridHeight) };
    (function() { t.getSearchCriteria = rt;
        t.onPageChanged = pt;
        t.providerId = h.providerId;
        t.pageIndex = 1;
        t.pageSize = 20;
        t.selectedRows = 0;
        t.selectType = 0;
        t.totalCount = 0;
        t.initData = yt;
        t.getOnlineConsultSumData = wt;
        t.onSearch = tt;
        t.onSearchTextKeyUp = bt;
        t.clearSearch = kt;
        t.toggleAdvancedSearch = dt;
        t.isGroup = h.isGroup;
        t.gridOptionKey = t.isGroup ? a.keys.groupDashboardOnlineConsultGridOption : a.keys.DashboardOnlineConsultGridOption;
        ut();
        t.uiState = { isAdvancedSearchOpen: !1 } })() }]);
dashboardModule.controller("GroupDashboardApptWorkCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "dashboardSvc", "appointmentConsultSvc", "loginContext", "patientUtil", "apptUtil", "appointmentSvc", "patientSvc", "eventAggregator", "aresNotification", "sessionCache", "officeOptionSvc", "aresDialog", "speechCallSvc", "userOptionSvc", "gridOptionUtil", "providerSvc", "enums", "aresSlidePanel", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it) { "use strict"; var rt = function() { var n = i.defer(),
                r = { startDate: moment(t.date).format("YYYY-MM-DD"), endDate: moment(t.date).add(1, "day").format("YYYY-MM-DD"), isCheckedIn: ft(), officeIds: t.isGroup ? t.selectedIdsStr : s.officeId, pageIndex: t.pageIndex, pageSize: t.pageSize, selectCode: t.selectCode, createUserIds: t.getUserIds(), isExcludeUsers: t.isExcludeUsers, isFirstVisit: t.apptIsFirstVisit, transactionCodeIds: t.transactionCodes, onlineConsultantIds: t.getConsultantIds(), checkInType: t.apptCheckInType }; return r.level = h.getPatientPermissionLevel(), n.resolve(r), n.promise },
        ft = function() { switch (t.selectStatus) {
                case "all":
                    return null;
                case "checkdIn":
                    return !0;
                case "notCheck":
                    return !1;
                default:
                    return null } },
        et = function() { var n = i.defer(); return rt().then(function(i) { e.getGroupApptWork(i).success(function(i) { ot(i.items);
                    t.pageData = i;
                    h.formatPatientHeadInfo(t.pageData.items).then(function(i) { if (t.pageData.items = i, i && i.length > 0) { var r = i[0].sumPrice;
                            r && (t.sumPrice = ut(r.toFixed(2))) } n.resolve(t.pageData) }) }) }), n.promise },
        ut = function(n) { n = n + ""; for (var t = /(-?\d+)(\d{3})/; t.test(n);) n = n.replace(t, "$1,$2"); return n },
        ot = function(n) { for (var t, i = 0; i < n.length; i++) t = n[i], t.id = t.appointId, t.startTimeStr = moment(t.startTime).format("HH:mm"), t.checkInTimeStr = t.checkInTime ? moment(t.checkInTime).format("HH:mm") : "", t.sexStr = u("toSexString")(t.sex), t.ageStr = u("toAgeYearString")(t.birth), t.isFirstVisitStr = u("toFirstVisit")(t.isFirstVisit), t.recordCreatedTimeStr = moment(t.recordCreatedTime).format("YYYY-MM-DD HH:mm"), t.actualPrice = t.actualPrice ? ut(t.actualPrice.toFixed(2)) : "0.00", t.consultantNameStr = u("toTenantNetworkConsultantName")(t.onlineConsultantId), t.firstVisitStr = u("toDateString")(t.firstVisit) },
        st = function() { h.createGroupFollowUpAppt(t.currentPatientId).then(function(n) { y.success("预约成功");
                v.publish(v.events.AppointmentCreated, n, "GroupDashboardFrontCtrl");
                t.refreshGrid() }) },
        ht = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        ct = function(n) { l.getAppointment(n).success(function(n) { c.editGroupOfficeFullAppt(n).then(function(n) { n && (y.success("修改成功"), t.refreshGrid()) }) }) },
        lt = function(n) { var r = n.state == tt.RevisitState.Pending.value || n.state == tt.RevisitState.Cancelled.value,
                i = it.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: "新建回访任务", revisitId: n.revisitId, patientId: n.patientId, isRevisitTask: !0 } } }, t);
            i.result.then(function() { t.refreshGrid();
                v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) },
        at = function(n) { var i = it.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: "新建回访", patientId: n.patientId } } }, t);
            i.result.then(function() { t.refreshGrid();
                v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) },
        vt = function(n) { var t = r.open({ animation: !0, backdrop: "static", template: "<patient-diagnose-record-dialog-view><\/patient-diagnose-record-dialog-view>", controller: "PatientDiagnoseRecordDialogCtrl", size: "lg", windowClass: "follow-up-appt-dialog", resolve: { host: function() { return { patientId: n.patientId } } } }) },
        yt = function() { var n = i.defer(); return d.getUserOption(g.keys.groupDashboardApptWorkGridOption).then(function(i) { t.showColumns = i != null ? i : "^";
                n.resolve(!0) }), n.promise },
        pt = function() { var n = angular.copy(t.transactionItems),
                i;
            n || (n = []);
            i = r.open({ animation: !0, backdrop: "static", template: "<item-dialog-view><\/item-dialog-view>", controller: "ItemDialogCtrl", windowClass: "followup-rule-edit-add-dialog", resolve: { host: function() { return { type: "transactioncode", list: n, officeId: t.selectedOfficeId } } } });
            i.result.then(function(n) { var u, r, f, e, i; if (n) { for (u = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "itemName"), r = "", i = 0; i < u.length; i++) { if (r.length > 10) { r += "..."; break } r += u[i] + "," } for (t.transactionCodeNames = r == "" || r == "全部," ? "全部" : r, angular.forEach(n.obj, function(n) { n.condType = "transactioncode" }), f = n.isSaveAll ? ["全部"] : _.pluck(n.obj, "id"), e = "", i = 0; i < f.length; i++) e += f[i] + ",";
                    t.transactionItems = n.obj;
                    t.transactionCodes = e;
                    t.refreshGrid() } }) },
        wt = function(n) { var t = i.defer(); return nt.getDepartmentGroupConsultants(n).success(function(n) { t.resolve(n) }), t.promise };
    (function() { t.updateCount = ht;
        t.refreshApptWork = et;
        t.showDiagnoseRecord = vt;
        t.showRevisitTask = lt;
        t.showRevisit = at;
        t.initSearchCriteria = rt;
        t.createAppt = st;
        t.editAppt = ct;
        t.userId = -1;
        t.apptIsFirstVisit = "";
        t.loadColumnsOption = yt;
        t.openTransactionItemsDialog = pt;
        t.getConsultants = wt;
        t.apptCheckInType = "" })() }]);
dashboardModule.controller("GroupDashboardFrontCtrl", ["$log", "$scope", "$modal", "$q", "$state", "aresNotification", "dashboardSvc", "eventAggregator", "appointmentSvc", "patientSvc", "appNav", "constants", "enums", "formatUtil", "practiceSvc", "reportSvc", "officeSvc", "officeOptionSvc", "loginContext", "patientUtil", function(n, t, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g) { "use strict"; var ut = function(n, t, i, r, u) { this.name = n;
            this.configName = t;
            this.stateName = i;
            this.icon = r;
            this.hintFunc = u;
            this.visible = !0 },
        rt = { providerId: 0, sumType: "今日" },
        ft = null,
        ot = null,
        nt = moment(Ares.today()).format("YYYY-MM-DD"),
        ii = moment(Ares.today()).add(1, "d").format("YYYY-MM-DD"),
        st = function() { ft = [new DashboardBlock("新增患者", "newRegister", "icon-user-follow", 10, !1, null, "#5296d8"), new DashboardBlock("新增预约", "newAppointment", "glyphicon glyphicon-calendar", 20, !1, null, "#00b39c"), new DashboardBlock("预约至当天", "todayAppt", "glyphicon glyphicon-calendar", 30, !1, null, "#d161a1"), new DashboardBlock("预约已到店", "todayCheckIn", "glyphicon glyphicon-calendar", 40, !1, null, "#f8b16d"), new DashboardBlock("预约未到店", "notCheckIn", "glyphicon glyphicon-calendar", 50, !1, null, "#5296d8"), new DashboardBlock("到店消费", "chargeCount", "glyphicon glyphicon-yen", 60, !1, null, "#00b39c"), new DashboardBlock("消费金额", "totalAmount", "glyphicon glyphicon-yen", 70, !0, null, "#d161a1"), new DashboardBlock("新增回访", "todayFollowup", "glyphicon glyphicon-earphone", 80, !1, null, "#f8b16d"), ];
            ot = [new ut("今日预约", "todayCheck", "dashBoard.groupTodayCheck", "icon-user", null), new ut("今日咨询", "todayOnlineConsult", "dashBoard.groupTodayOnlineConsult", "icon-user", lt), new ut("今日回访", "todayRevisit", "dashBoard.groupTodayRevisit", "icon-user", at), ];
            t.listBlocks = ot },
        ht = function() { var n = r.open({ animation: !0, backdrop: "static", template: "<my-achievements-setting-view><\/my-achievements-setting-view>", controller: "MyAchievementsSettingCtrl", windowClass: "myachievemnet-setting-dialog", size: "sm", resolve: { host: function() { return null } } });
            n.result.then(function(n) { n && (o.clearConfigCache("GroupMyAchivement"), o.clearConfigCache("Dashboard"), it(!0)) }) },
        it = function(n) { o.loadConfig("Dashboard").then(function(n) { var i = _.find(n, { configName: "protectionAmount" }),
                    r = !1;
                i && (r = i.configValue.toLowerCase() == "true");
                t.isProtectedMode = r });
            o.loadConfig("GroupMyAchivement").then(function(i) { var f = 1,
                    u, r;
                angular.forEach(i, function(n) { var t = _.find(ft, { configName: n.configName });
                    t && (t.showOrder = f++, t.visible = n.configValue.toUpperCase() == "TRUE") });
                u = g.getPatientPermissionLevel();
                rt.level = t.isLeader ? u : 1;
                rt.isGroup = d.isGroup;
                r = [];
                o.getGroupFrontSumByFilter(rt).success(function(i) { angular.forEach(i, function(n) { var i = _.find(ft, { type: n.itemName }),
                            t;
                        n.itemName == "消费金额" ? (t = _.clone(i), t.value = ct(n.itemValue.toFixed(2)), t.text = n.itemName, r.push(t)) : i && i.visible && (t = _.clone(i), t.value = n.itemValue, t.text = n.itemName, r.push(t)) });
                    r = _.sortBy(r, "showOrder");
                    t.summaryBlocks = r;
                    n && tt() }) }) },
        ct = function(n) { n = n + ""; for (var t = /(-?\d+)(\d{3})/; t.test(n);) n = n.replace(t, "$1,$2"); return n },
        ri = function(n) { var i = u.defer(),
                r = { startDate: moment(nt).format("YYYY-MM-DD"), endDate: moment(nt).add(1, "day").format("YYYY-MM-DD"), isCheckedIn: 0, officeId: -1, pageIndex: 1, pageSize: 10, selectCode: "", userId: -1, level: t.level }; return o.getGroupApptWork(r).success(function(t) { n.hint = t.totalCount;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        lt = function(n) { var i = u.defer(),
                r = { startDate: moment(nt).format("YYYY-MM-DD"), endDate: moment(nt).add(1, "day").format("YYYY-MM-DD"), officeId: d.isGroup ? -1 : d.officeId, pageIndex: 1, pageSize: 10, selectCode: "", userId: -1, level: t.level }; return o.getGroupOnlineConsult(r).success(function(t) { n.hint = t.totalCount;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        at = function(n) { var i = u.defer(),
                r = { startDate: moment(nt).format("YYYY-MM-DD"), endDate: moment(nt).add(1, "day").format("YYYY-MM-DD"), state: -1, officeId: d.isGroup ? -1 : d.officeId, pageIndex: 1, pageSize: 10, selectCode: "", userId: -1, level: t.level }; return o.getGroupRevisit(r).success(function(t) { n.hint = t.totalCount;
                i.resolve() }).error(function() { i.resolve() }), i.promise },
        tt = function(n, i) { if (n = n || t.listBlocks, i = i || 0, i < n.length) { var r = n[i],
                    u = i + 1;
                r.hintFunc ? r.hintFunc(r).then(function() { tt(n, u) }) : tt(n, u) } },
        vt = function() { var n = et("todayCheck");
            n && tt(t.listBlocks, n) },
        yt = function() { var n = et("todayOnlineConsult");
            n && tt(t.listBlocks, n) },
        pt = function() { var n = et("todayRevisit");
            n && tt(t.listBlocks, n) },
        ui = function() { return t.doctorId > -1 ? t.doctorId : null },
        wt = function() { s.subscribe(t, s.events.AppointmentCreated, bt);
            s.subscribe(t, s.events.OnlineConsultCreated, kt);
            s.subscribe(t, s.events.OnlineRevisitCreated, dt) },
        bt = function() { vt();
            it(!0) },
        kt = function() { yt() },
        dt = function() { pt();
            it(!0) },
        gt = function(n, i) { var u = f.current.name,
                r = _.find(t.listBlocks, { stateName: u });
            r && (r.hint = n, i != undefined && (r.hintWarn = i)) },
        ni = function(n) { t.isLeader = n;
            it(!1) },
        ti = function() { var r = d.roleDashboardConfig ? d.roleDashboardConfig.ConfigData[0].Items : null,
                i, n, f, u; if (r)
                for (i = 0; i < r.length; i++)
                    for (n = t.listBlocks.length - 1; n >= 0; n--) f = t.listBlocks[n], u = r[i], f.configName == u.Name && u.Value.toUpperCase() == "FALSE" && t.listBlocks.splice(n, 1) },
        et = function(n) { var u = d.roleDashboardConfig ? d.roleDashboardConfig.ConfigData[0].Items : null,
                r, e, f; if (u) { for (r = t.listBlocks.length - 1; r >= 0; r--)
                    if (e = t.listBlocks[r], f = u[i], n == f.Name) return r } else return null; return null };
    (function() { t.showMyAchievementsSettingDialog = ht;
        t.refreshDashboardBlockHint = gt;
        t.refreshSummaryBlockByOption = ni;
        t.isProtectedMode = !1;
        t.level = g.getPatientPermissionLevel();
        wt();
        st();
        ti();
        it(!0) })() }]);
dashboardModule.controller("GroupDashboardOnlineConsultCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "dashboardSvc", "appointmentConsultSvc", "loginContext", "patientUtil", "apptUtil", "appointmentSvc", "patientSvc", "eventAggregator", "aresNotification", "sessionCache", "officeOptionSvc", "aresDialog", "speechCallSvc", "aresSlidePanel", "onlineConsultSvc", "userOptionSvc", "gridOptionUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt) { "use strict"; var it = function() { var n = i.defer(),
                r = { startDate: moment(t.date).format("YYYY-MM-DD"), endDate: moment(t.date).add(1, "day").format("YYYY-MM-DD"), officeId: t.officeId, pageIndex: t.pageIndex, pageSize: t.pageSize, selectCode: t.selectCode, userId: t.userId, isNeedAppt: !0 }; return r.level = h.getPatientPermissionLevel(), n.resolve(r), n.promise },
        rt = function() { var n = i.defer(); return it().then(function(i) { e.getGroupOnlineConsult(i).success(function(i) { ut(i.items);
                    t.pageData = i;
                    h.formatPatientHeadInfo(t.pageData.items).then(function(i) { t.pageData.items = i;
                        n.resolve(t.pageData) }) }) }), n.promise },
        ut = function(n) { for (var t, i = 0; i < n.length; i++) t = n[i], t.index = i + 1, t.id = t.onlineConsultId, t.sexStr = u("toSexString")(t.sex), t.ageStr = u("toAgeYearString")(t.birth), t.consultTimeStr = moment(t.consultTime).format("YYYY-MM-DD HH:mm"), t.lastAppt = { id: t.patientLastApptId } },
        ft = function() { var n = d.open("<online-consult-detail-edit-view><\/online-consult-detail-edit-view>", "OnlineConsultDetailEditCtrl", { host: function() { return { title: "新建咨询" } } }, t);
            n.result.then(function() { v.publish(v.events.OnlineConsultCreated, null, "GroupDashboardFrontCtrl");
                t.refreshGrid() }) },
        et = function(n) { var i = d.open("<online-consult-detail-edit-view><\/online-consult-detail-edit-view>", "OnlineConsultDetailEditCtrl", { host: function() { return { title: "编辑咨询", consultId: n.onlineConsultId, patientId: n.patientId } } }, t);
            i.result.then(function() { t.refreshGrid() }) },
        ot = function(n) { b.confirm("信息", "确定要删除吗！").then(function() { g.deleteOnlineConsult(n).success(function() { y.success("删除成功！");
                    t.refreshGrid();
                    v.publish(v.events.OnlineConsultCreated, null, "GroupDashboardFrontCtrl") }) }) },
        st = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        ht = function() { var n = i.defer(); return nt.getUserOption(tt.keys.groupDashboardOnlineConsultGridOption).then(function(i) { t.showColumns = i != null ? i : "^";
                n.resolve(!0) }), n.promise };
    (function() { t.updateCount = st;
        t.refreshOnlineConsult = rt;
        t.initSearchCriteria = it;
        t.createConsult = ft;
        t.deleteOnlineConsult = ot;
        t.editConsult = et;
        t.userId = -1;
        t.loadColumnsOption = ht })() }]);
dashboardModule.controller("GroupDashboardRevisitCtrl", ["$log", "$scope", "$q", "$modal", "$filter", "$timeout", "dashboardSvc", "appointmentConsultSvc", "loginContext", "patientUtil", "apptUtil", "appointmentSvc", "patientSvc", "eventAggregator", "aresNotification", "sessionCache", "officeOptionSvc", "aresDialog", "speechCallSvc", "aresSlidePanel", "revisitSvc", "enums", "userOptionSvc", "gridOptionUtil", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it) { "use strict"; var rt = function() { var n = i.defer(),
                r = { startDate: moment(t.date).format("YYYY-MM-DD"), endDate: moment(t.date).add(1, "day").format("YYYY-MM-DD"), state: t.revisitState, officeId: t.officeId, pageIndex: t.pageIndex, pageSize: t.pageSize, selectCode: t.selectCode, userId: t.userId }; return r.level = t.permissionLevel, n.resolve(r), n.promise },
        ut = function() { var n = i.defer(); return rt().then(function(i) { e.getGroupRevisit(i).success(function(i) { ft(i.items);
                    t.pageData = i;
                    h.formatPatientHeadInfo(t.pageData.items).then(function(i) { t.pageData.items = i;
                        n.resolve(t.pageData) }) }) }), n.promise },
        ft = function(n) { for (var t, i = 0; i < n.length; i++) t = n[i], t.index = i + 1, t.id = t.revisitId, t.planTimeStr = t.planTime ? moment(t.planTime).format("YYYY-MM-DD HH:mm") : "", t.visitTimeStr = t.visitTime ? moment(t.visitTime).format("YYYY-MM-DD HH:mm") : "", t.sexStr = u("toSexString")(t.sex), t.ageStr = u("toAgeYearString")(t.birth), t.stateStr = et(t.state) },
        et = function(n) { switch (n) {
                case 0:
                    return "待计划";
                case 1:
                    return "已完成";
                case 2:
                    return "未成功";
                case 3:
                    return "已取消";
                default:
                    return "" } },
        ot = function() { var n = d.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: "新建回访" } } }, t);
            n.result.then(function() { t.refreshGrid();
                v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) },
        st = function() { var n = d.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: "新建回访任务", isRevisitTask: !0 } } }, t);
            n.result.then(function() { t.refreshGrid();
                v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) },
        ht = function(n) { var i = n.state == nt.RevisitState.Pending.value || n.state == nt.RevisitState.Cancelled.value,
                r = d.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: i ? "编辑回访任务" : "编辑回访", revisitId: n.revisitId, patientId: n.patientId, isRevisitTask: i } } }, t);
            r.result.then(function() { t.refreshGrid();
                v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) },
        ct = function(n) { var i = d.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: "执行回访", revisitId: n.revisitId, patientId: n.patientId } } }, t);
            i.result.then(function() { t.refreshGrid();
                v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) },
        lt = function(n) { b.confirm("信息", "确定要删除吗！").then(function() { g.deleteRevisit(n).success(function() { y.success("删除成功！");
                    t.refreshGrid();
                    v.publish(v.events.OnlineRevisitCreated, null, "GroupDashboardFrontCtrl") }) }) },
        at = function() { var n = t.pageData ? t.pageData.totalCount : 0;
            t.$parent && t.$parent.refreshDashboardBlockHint && t.$parent.refreshDashboardBlockHint(n) },
        vt = function() { var n = i.defer(); return tt.getUserOption(it.keys.groupDashboardRevisitGridOption).then(function(i) { t.showColumns = i != null ? i : "^";
                n.resolve(!0) }), n.promise };
    (function() { t.updateCount = at;
        t.refreshRevisit = ut;
        t.createRevisit = ot;
        t.createRevisitTask = st;
        t.editRevisit = ht;
        t.executeRevisit = ct;
        t.deleteRevisit = lt;
        t.initSearchCriteria = rt;
        t.userId = -1;
        t.loadColumnsOption = vt;
        t.permissionLevel = s.dashboardRoleType == "前台" ? 0 : h.getPatientPermissionLevel() })() }]);
dashboardModule.directive("todayCheckedInPrintView", ["$q", "$log", "$timeout", "pictureSvc", "$filter", "$sce", "toothUtil", function(n, t, i, r, u, f) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/print/today-checked-in-print-view.html", link: function(t, e) { var o = Ares.MergeField,
                s = [],
                l = function(n) { var i, h, f, c, e, r;
                    n && (n.patient.birth ? (i = moment(n.patient.birth, "YYYY-MM-DD"), i.isValid() || (i = moment(n.patient.birth, "YYYYMMDD")), i.isValid() && (r = moment(Ares.today()), h = r.diff(i, "years"), t.ignoreAgeChanged = !0, t.age = h)) : t.age = "", f = "", f = n.patientHead && n.patientHead.tags && n.patientHead.tags.length > 0 ? n.patientHead.tags[0].itemName : n.patient.patientType, c = a(n), e = 0, e = n.waitCount || n.waitCount == 0 ? n.waitCount : "", r = Ares.today(), s = [new o("{患者姓名}", n.patient.name || ""), new o("{病历号}", n.patient.privateId || ""), new o("{性别}", u("toSexString")(n.patient.sex)), new o("{年龄}", t.age), new o("{昵称}", n.patient.nickName || ""), new o("{就诊日期}", u("toDateString")(n.appointmentTime.checkInTime)), new o("{打印时间}", u("toLongDateTimeString")(new Date)), new o("{挂号时间}", u("toLongDateTimeString")(n.appointmentTime.checkInTime)), new o("{患者类型}", f || ""), new o("{挂号序号}", n.checkInNo || ""), new o("{候诊人数}", t.checkInIndex), new o("{预约医生}", n.doctorName || ""), new o("{预约助理}", n.assistantName || ""), new o("{预约咨询师}", n.consultantName || ""), new o("{预约时间}", n.startTimeLongStr || ""), new o("{预约科室}", n.department || ""), new o("{预约诊室}", n.operatoryId || ""), new o("{预约项目}", n.transactionCodeStr || ""), new o("{诊所地址}", t.office.address || ""), new o("{诊所名称}", t.office.name || ""), new o("{诊所电话}", t.office.phoneNumber || ""), new o("{挂号类型}", n.checkInType || ""), new o("{病历号条码}", c || ""), new o("{等待人数}", e), new o("{条码宽度}", (n.barCodeWidth || "430") + "px"), ], t.templatePicture && s.push(new o("{URL}", t.templatePicture.filePath))) },
                a = function(n) { return e.find("#barCodeDiv").html(""), e.find("#barCodeDiv").kendoBarcode({ value: n.patient.privateId, type: "code128", width: n.barCodeWidth || 430, height: n.barCodeHeight || 100 }), e.find("#barCodeDiv").html() },
                v = function(i, u) { var f = n.defer(); return i.pictureId > 0 ? r.getPicture(i.pictureId).success(function(n) { t.templatePicture = n;
                        h(i, u);
                        f.resolve() }) : (h(i, u), f.resolve()), f.promise },
                h = function(n, i) { var r = n.templateContent;
                    l(i);
                    r = r.replace(/[\[]/g, "{");
                    r = r.replace(/]/g, "}");
                    angular.forEach(s, function(n) { r = r.replace(n.key, n.value) });
                    n.printTemplate = f.trustAsHtml(r);
                    t.printPage = n.printTemplate },
                y = function(i, r) { var f = n.defer(),
                        u, o; return t.printTemplate || (t.printTemplate = r ? e.find("#todayCheckedInSpeechTemplate").html() : e.find("#todayCheckedInTemplate").html()), u = angular.copy(t.printTemplate), u && (u.templateContent || u.templateContent == "") ? (u.templateContent.match(/条码宽度：(\d+)/) && (i.barCodeWidth = parseInt(u.templateContent.match(/条码宽度：(\d+)/)[1])), u.templateContent.match(/条码高度：(\d+)/) && (i.barCodeHeight = parseInt(u.templateContent.match(/条码高度：(\d+)/)[1]))) : u && (u.match(/条码宽度：(\d+)/) || u.match(/条码高度：(\d+)/)) && (u.match(/条码宽度：(\d+)/) && (i.barCodeWidth = parseInt(u.match(/条码宽度：(\d+)/)[1])), u.match(/条码高度：(\d+)/) && (i.barCodeHeight = parseInt(u.match(/条码高度：(\d+)/)[1]))), u ? u.isPrivateTemplate ? v(u, i).then(() => t.privateTemplate = t.printTemplate, c(u)).then(() => f.resolve()) : (o = { templateContent: u }, h(o, i), c(u).then(() => f.resolve())) : f.resolve(), f.promise },
                c = function(n) { var u = 0,
                        e = 0,
                        f = 50,
                        o = 0,
                        r, s; return n.templateStyle && (r = n.templateStyle.split(","), r.length == 4 && (u = r[0], e = r[1], f = r[2], o = r[3])), f = t.isEmrCustomTemplateEnabled ? 75 : f, u = t.isEmrCustomTemplateEnabled ? 10 : u, s = "" + u + "px " + o + "px " + e + "px " + f + "px", i(function() { $("#" + n.templateCode + " #templateBody").css("margin", s) }, 500) };
            (function() { t.refreshTemplate = y;
                t.printPage = {} })() } } }]);
dashboardModule.directive("apptStateMonitor", ["$timeout", "$interval", function(n, t) { "use strict"; return { restrict: "A", link: function(i, r, u) { var o = u.apptStateMonitor,
                f = null,
                s = null,
                c = function() { f || (f = t(function() { e() }, 3e5));
                    n(function() { e(!0);
                        i.refreshedTime && i.$watch("refreshedTime", function() { e() }) }, 200) },
                l = function() { f && (t.cancel(f), f = null) },
                h = function(n) { return n < 60 ? Math.floor(n / 15) * 15 + "分钟" : Math.floor(n / 60) + "小时" },
                e = function(n) { var t, u; if (!s || (t = new Date, u = moment(t).diff(s, "seconds"), !(u < 1))) { var f = Ares.today(),
                            e = new Ares.DateRange(f, moment(f).add(1, "d").toDate()),
                            t = new Date;
                        angular.forEach(i[o], function(i) { var f = i.stateStr,
                                u = r.find("#apptState" + i.id),
                                s, o;
                            f == "已确认" ? u.addClass("patient-confirmed") : f == "已挂号" ? u.addClass("patient-checked-in") : f == "治疗中" ? u.addClass("patient-seated") : f == "治疗完成" ? u.addClass("patient-completed") : f == "已结账" ? u.addClass("patient-checked-out") : f == "已离开" && u.addClass("patient-left");
                            delete i._lateMinutes;
                            delete i._waitMinutes;
                            n && (delete i._checkInTime, delete i._scheduleTime);
                            s = e.contains(i.startTime);
                            s && f == "已挂号" ? (i._checkInTime || (i.checkInTime ? i._checkInTime = moment(i.checkInTime) : i.appointmentTime && i.appointmentTime.checkInTime ? i._checkInTime = moment(i.appointmentTime.checkInTime) : i.stateLastUpdated && (i._checkInTime = moment(i.stateLastUpdated))), i._checkInTime && (i._waitMinutes = -i._checkInTime.diff(t, "minutes"))) : s && (f == "未确认" || f == "已确认") && (i._scheduleTime || (i._scheduleTime = moment(i.startTime)), i._scheduleTime && (i._lateMinutes = -i._scheduleTime.diff(t, "minutes")));
                            (i._lateMinutes || i._waitMinutes) && (i._waitMinutes >= 15 && (u.addClass("long-wait"), o = "等待" + h(i._waitMinutes), u.html(o)), i._lateMinutes >= 15 && (u.addClass("long-late"), o = "迟到" + h(i._lateMinutes), u.html(o))) });
                        s = Ares.timestamp() } };
            (function() { i.refreshApptStates = e;
                i.$watch(o, function() { i[o] && c() });
                i.$on("$destroy", function() { l() }) })() } } }]);
dashboardModule.factory("customerServiceUtil", ["$log", "$q", "$modal", "aresSlidePanel", "productSvc", "productUnitySvc", "kendoUtil", function(n, t, i, r, u, f, e) { "use strict"; var o = [{ template: "<div class='double-line-text' title='#: patientId #'><a data-patient-id ='#: patientId #'>#: patientName #<\/a><\/div>", field: "patientName", title: "患者姓名", headerAttributes: { "class": "cell-left", style: "min-width:150px" }, attributes: { "class": "cell-left" }, width: "150px", locked: !0, hidden: !1 }, { hidden: !1, field: "privateId", title: "病历号", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "patientSexual", title: "性别", width: "50px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "age", title: "年龄", width: "95px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "mobile", title: "手机", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "officeName", title: "所属机构", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "onlineConsultantName", title: "网电", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "onlineConsultantDepartment", title: "网电科室", width: "150px", attributes: { "class": "cell-left" } }, { field: "firstVisit", hidden: !1, title: "首次到店", width: "160px", attributes: { "class": "cell-left" }, template: function(n) { return e.datetimeFormat(n.firstVisit) } }, { hidden: !1, field: "consultantName", title: "咨询师", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "doctorName", title: "初诊医生", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !1, field: "lastVisit", title: "上次到店", width: "160px", attributes: { "class": "cell-left" }, template: function(n) { return e.datetimeFormat(n.lastVisit) } }, { hidden: !0, field: "sourceTypeL1", title: "患者来源一级", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "sourceTypeL2", title: "患者来源二级", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "sourceTypeL3", title: "患者来源三级", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "patientType", title: "患者类型", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "birth", title: "生日", format: "{0:MM-dd}", width: "100px", attributes: { "class": "cell-left" }, template: function(n) { return e.dateFormat(n.birth) } }, { hidden: !0, field: "lastDoctorName", title: "上次就诊医生", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "membershipName", title: "会员类型", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "recordCreatedTime", title: "创建时间", width: "160px", attributes: { "class": "cell-left" }, template: function(n) { return e.datetimeFormat(n.recordCreatedTime) } }, { hidden: !0, field: "consultItems", title: "网电咨询项目", width: "150px", attributes: { "class": "cell-left" }, template: function(n) { var t = n.consultItems || ""; return "<span title=" + t + ">" + t + "<\/span>" } }, { hidden: !0, field: "patientTag", title: "患者标签", width: "150px", attributes: { "class": "cell-left" }, template: function(n) { var t = n.patientTag || ""; return "<span title=" + t + ">" + t + "<\/span>" } }, { hidden: !0, field: "tagStr", title: "我的标签", width: "150px", attributes: { "class": "cell-left" }, template: function(n) { var t = n.tagStr || ""; return "<span title=" + t + ">" + t + "<\/span>" } }, { hidden: !0, field: "hasCheckedIn", title: "是否到店", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "createdName", title: "创建人", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "isBindWeixin", title: "微信绑定", width: "150px", attributes: { "class": "cell-left" }, template: function(n) { return n.isBindWeixin ? "已绑定" : "未绑定" } }, { hidden: !0, field: "notes", title: "备注", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "chargeItemStr", title: "上次消费项目", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "nationality", title: "国籍", width: "150px", attributes: { "class": "cell-left" } }, { hidden: !0, field: "chargeOrderIsDealt", title: "收费单是否成交", width: "150px", attributes: { "class": "cell-left" }, template: function(n) { return n.chargeOrderIsDealt ? "是" : "否" } }, ]; return { customerServiceColumn: o } }]);
dashboardModule.directive("accountStatementContainerView", ["$compile", "$timeout", "$q", "aresDialog", "dashboardSvc", "loginContext", "practiceSvc", "aresConfirmDialog", "aresNotification", function(n, t, i, r, u, f, e, o, s) { return { restrict: "E", controller: "Reportv2ContainerCtrl", scope: { reportName: "=" }, templateUrl: "/app/dashboard/views/account-statement-container-view.html", link: function(t, i) { var r, c = function() { r = t.$watch("reportName", function(n) { n && (t.initReportConfig(), t.itemGridOption = n) });
                    t.$on("$destroy", function() { r && r() });
                    t.$on("criteriaChange", function(n, i, r) { i && r && r.name == "DashboardDailyCheckCashflowSummaryReport" && (i.startTime && (t.startTime = i.startTime.indexOf("@") > 0 ? h(i.startTime, 0).toDate() : i.startTime), i.endTime && (t.endTime = i.endTime.indexOf("@") > 0 ? h(i.endTime, 1).toDate() : i.endTime)) }) },
                h = function(n, t) { var r = n.substring(9).split(","),
                        f = parseInt(r[0]),
                        i = r[1],
                        u = moment().add(f, i); return t == 0 ? u.startOf(i) : u.endOf(i) },
                l = function() { e.getProvider(f.providerId).success(function(n) { t.accountName = n.name;
                        t.accountStateNumber = moment(new Date).format("YYYYMMDDHHmmsss"); var r = t.sumInfo.amount ? t.sumInfo.amount.replace(",", "") : 0,
                            i = { id: 0, statementNumber: t.accountStateNumber, accountorName: t.accountName, accountorId: f.providerId, accountStartTime: moment(t.startTime).format("YYYY-MM-DD HH:mm:ss"), accountEndTime: moment(t.endTime).format("YYYY-MM-DD HH:mm:ss"), finalPrice: r, comment: "", orderCount: parseInt(t.sumInfo.orderCount) },
                            e = "<p>本次对账时间：<\/p><p>起：" + i.accountStartTime + " <\/p><p>止： " + i.accountEndTime + "<\/p><p>确认金额：" + i.finalPrice + " ，共 " + i.orderCount + " 张单据<\/p>";
                        o.info({ message: e, showCancelBtn: !0 }).then(function() { u.createAccountStatement(i).success(function(n) { t.confirmedAccountStatement = n;
                                s.success("对账成功"); return }) }) }) },
                a = function() { var r = i.find(".batch-commands").html(); return n(r)(t) };
            (function() { c();
                t.isRealTimeMode = !0;
                t.isShowExport = !0;
                t.isAllowedExport = !0;
                t.isShowPrint = !0;
                t.getCustomizeContent = a;
                t.saveAccountStatement = l;
                t.$on("sumInfoChange", function(n, i) { t.sumInfo = i }) })() } } }]);
dashboardModule.directive("accountStatementSetContainerView", ["$log", "$timeout", "$q", "dataDicSvc", "$rootScope", "permissionProvider", function() { return { restrict: "E", controller: "Reportv2SetContainerCtrl", scope: { setName: "@" }, templateUrl: "/app/dashboard/views/account-statement-set-container-view.html", link: function(n) {
            (function() { n.init() })() } } }]);
dashboardModule.directive("accountStatementView", ["$log", "$timeout", "$filter", "$window", "$state", "appNav", "enums", "eventAggregator", "permissionProvider", function() { "use strict"; return { restrict: "E", replace: !0, controller: "AccountStatementCtrl", templateUrl: "/app/dashboard/views/account-statement-view.html", scope: { officeId: "=" }, link: function(n) { n.priceToFixed = function(n) { return Ares.priceToFixed(n) } } } }]);
dashboardModule.directive("apptCancelListView", ["$log", "$timeout", "$modal", "$window", "appNav", "appointmentSvc", "dataDicSvc", "localCache", "gridOptionUtil", function(n, t, i, r, u, f, e, o, s) { return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/appt-cancel-list-view.html", scope: { officeId: "=" }, controller: "ApptCancelListCtrl", link: function(n, t) { var h = Ares.kendoGridUtil(r, n),
                i = null,
                a = null,
                c = o.getCache(o.keys.CancelApptColumnOption),
                f = c.loadObject();
            f = _.isArray(f) ? f : []; var v = [{ text: "重新预约", action: "rebookAppt", icon: "glyphicon-share" }, ],
                y = function() { n.gridOption = { scrollable: !0, resizable: !0, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "patient.name", title: "姓名", width: "100px", template: function() { return '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "patient.mobile", title: "手机", width: "100px" }, { field: "startTimeLongStr", title: "预约时间", width: "120px" }, { field: "doctorName", title: "预约医生", width: "120px" }, { field: "transactionNames", title: "预约项目", width: "120px", attributes: { "class": "td-class" } }, { field: "stateLastUpdatedStr", title: "取消时间", width: "120px" }, { field: "notes", title: "备注", width: "180px" }, { template: h.commandTemplate, title: "", width: "100px", code: "cancel" }], columnResize: function(n) { s.setColumnWidthCache(n, !0, c, f, a) } };
                    s.formatColumns(n.gridOption.columns, n.gridOption.columns, f);
                    f.length > 0 && (f = []);
                    angular.forEach(n.gridOption.columns, function(n) { f.push({ code: n.field || n.code, width: n.width }) }) },
                l = function(r) { var f, e, u, o;
                    i ? i.dataSource.data(n.cancelAppts) : i = t.find("#cancelList").data("kendoGrid");
                    f = [{ field: "stateLastUpdatedStr", dir: "desc" }];
                    i.dataSource.sort(f);
                    r && (e = i.dataSource, u = e.get(r), u && (o = i.element.find("tbody>tr[data-uid=" + u.uid + "]"), i.select(o))) },
                p = function(t, i, r) { n.$apply(function() { var t = w(r),
                            f = t.patient; switch (i) {
                            case "goToPatient":
                                u.goToPatient(t.patient.id); break;
                            case "rebookAppt":
                                n.rebookAppt(t, function() { l(r) }) } }) },
                w = function(t) { return _.find(n.cancelAppts, function(n) { return n.id == t }) },
                b = function() { e.doctorDic.loadActive().then(function(i) { var f = _.clone(i),
                            e = { id: -1, name: "全部" },
                            r, u;
                        f.splice(0, 0, e);
                        r = t.find("#doctorInput");
                        r.kendoDropDownList({ dataSource: f, placeholder: "", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.doctorId = i.id } });
                        u = r.data("kendoDropDownList");
                        n.doctorId ? u.value(n.doctorId) : u.value(e.id) }) },
                k = function() { $("#cancelTodayInput").kendoDropDownList({ dataSource: n.daysBeforeTodayOptions, placeholder: "", dataTextField: "text", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                            n.daysBeforeTodayOption = i } }); var t = $("#cancelTodayInput").data("kendoDropDownList");
                    n.daysBeforeTodayOption && n.daysBeforeTodayOption.id >= -1 ? t.value(n.daysBeforeTodayOption.id) : t.value(1) },
                d = function() { i && i.saveAsExcel() };
            (function() { n.commands = v;
                n.onCommandClick = p;
                n.exportExcel = d;
                y();
                b();
                k();
                n.$watch("cancelAppts", function() { n.updateCount();
                    l() });
                n.$on("$destroy", function() { h.dispose() }) })() } } }]);
dashboardModule.directive("apptPendingListView", ["$log", "$timeout", "$modal", "$window", "appNav", "appointmentSvc", "dataDicSvc", "dashboardSvc", "gridOptionUtil", "localCache", "permissionProvider", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l) { return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/appt-pending-list-view.html", scope: {}, controller: "ApptPendingListCtrl", link: function(n, i) { var b = null,
                y = h.getCache(h.keys.PendingApptColumnOption),
                a = y.loadObject();
            a = _.isArray(a) ? a : []; var p = Ares.kendoGridUtil(r, n),
                f, w = [new Ares.Pair(1, "明天"), new Ares.Pair(2, "后天"), new Ares.Pair(3, "大后天"), new Ares.Pair(0, "自定义"), ],
                k = function() { var t = i.find("#pendingList"),
                        r = t.offset().top,
                        u = $(window).height() - r - 30;
                    n.gridOption = { scrollable: !0, resizable: !0, sortable: !0, selectable: "single", height: u, model: { id: "id" }, columns: [{ field: "patient.name", title: "姓名", width: "100px", template: function(n) { return n.patientHead && n.patientHead.tags && n.patientHead.tags.length > 0 && angular.forEach(n.patientHead.tags, function(n) { n.textColor = n.itemValue ? Ares.getForegroundColor(n.itemValue) : Ares.getForegroundColor("#fff") }), '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "patient.privateId", title: "病历号", width: "100px" }, { field: "patient.mobile", title: "手机", width: "100px" }, { field: "startTimeStr", title: "待定日期", width: "100px" }, { field: "recordCreatedTimeStr", title: "创建日期", width: "120px" }, { field: "doctorName", title: "预约医生", width: "120px" }, { field: "transactionNames", title: "预约项目", width: "120px", attributes: { "class": "td-class" } }, { field: "notes", title: "备注", width: "150px" }, { template: p.commandTemplate, title: "", width: "120px", code: "pendingOption" }], columnResize: function(n) { s.setColumnWidthCache(n, !0, y, a, b) } };
                    s.formatColumns(n.gridOption.columns, n.gridOption.columns, a);
                    a.length > 0 && (a = []);
                    angular.forEach(n.gridOption.columns, function(n) { a.push({ code: n.field || n.code, width: n.width }) }) },
                d = [{ text: "重新预约", action: "rebookAppt", icon: "glyphicon-share" }, { text: "删除", action: "deleteAppt", icon: "glyphicon-remove" }, ],
                g = function(t, i, r) { n.$apply(function() { var t = nt(r),
                            f = t.patient; switch (i) {
                            case "goToPatient":
                                u.goToPatient(t.patient.id); break;
                            case "rebookAppt":
                                n.rebookAppt(t, function() { v(r) }); break;
                            case "deleteAppt":
                                n.deleteAppt(t, function() { v(r) }) } }) },
                v = function(t) { var u, e, r, o;
                    f || (f = i.find("#pendingList").data("kendoGrid"));
                    f.dataSource.data(n.pendingAppts);
                    u = [{ field: "startTimeStr", dir: "desc" }];
                    f.dataSource.sort(u);
                    t && (e = f.dataSource, r = e.get(t), r && (o = f.element.find("tbody>tr[data-uid=" + r.uid + "]"), f.select(o))) },
                nt = function(t) { return _.find(n.pendingAppts, function(n) { return n.id == t }) },
                tt = function() { var r = i.find("#toDateInput");
                    r.kendoDropDownList({ dataSource: w, dataTextField: "item2", dataValueField: "item1", value: n.criteria.daysAfterToday, select: function(i) { var r = this.dataItem(i.item.index());
                            t(function() { n.criteria.daysAfterToday = r.item1 }) } }) },
                it = function() { e.doctorDic.loadActive().then(function(t) { var r = _.clone(t),
                            u;
                        r.splice(0, 0, { id: -1, name: "全部" });
                        u = i.find("#doctorInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "name", dataValueField: "id", value: n.criteria.doctorId, select: function(t) { var i = this.dataItem(t.item.index());
                                n.criteria.doctorId = i.id } }) }) },
                rt = function() { f && f.saveAsExcel() },
                rt = function() { if (f) { var t = { criteria: n.searchCriteria, columns: f.columns };
                        o.exportApptPending(t) } },
                ut = function() { var r = i.find("#daySelectBtn");
                    r.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectBtn").datepicker("hide");
                        n.isInitialize ? n.isInitialize = !1 : t(function() { n.date = i.date;
                            n.search() }, 100) });
                    r.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                ft = function() { $("#daySelectBtn").datepicker("update", moment(n.date).format("YYYY-MM-DD")) },
                et = function(n, t) { if (n.action === "rebookAppt") { var i = c.isEditAllApptAllowed || t.recordCreatedUser == l.userId;
                        n.isDisabled = !i } };
            (function() { n.commands = d;
                n.onCommandClick = g;
                n.toDateOptions = w;
                n.exportExcel = rt;
                n.refreshDate = ft;
                n.formatCommand = et;
                k();
                ut();
                tt();
                it();
                n.$watch("pendingAppts", function() { n.updateCount();
                    v() });
                n.$on("$destroy", function() { p.dispose() }) })() } } }]);
dashboardModule.directive("birthPatientView", ["$log", "$timeout", "$compile", "$filter", "$window", "localCache", "gridOptionUtil", function(n, t, i, r, u, f, e) { "use strict"; return { restrict: "E", replace: !0, controller: "BirthPatientCtrl", templateUrl: "/app/dashboard/views/birth-patient-view.html", scope: { officeId: "=" }, link: function(n, o) { var a = Ares.kendoGridUtil(u, n),
                h = null,
                p = null,
                v = f.getCache(f.keys.BirthRemainColumnOption),
                s = v.loadObject(),
                c = !1;
            s = _.isArray(s) ? s : []; var l = 20,
                y = function() { var r = o.find("#patientList"),
                        y = r.offset().top,
                        a = u.innerHeight - 200,
                        t = e.getDefaultGridOption({ transport: { read: function(t) { n.pageIndex = t.data.page || 1;
                                    n.pageSize = t.data.pageSize || l;
                                    c ? t.success({ data: [], total: Number.MAX_SAFE_INTEGER }) : n.refresh().then(function() { t.success({ data: n.patientList, total: n.totalCount });
                                        i(r)(n) }) } }, serverPaging: !0, pageSize: n.pageSize || l, schema: { data: "data", total: "total" } }, w(), a),
                        f;
                    t.scrollable = !0;
                    t.resizable = !0;
                    t.sortable = !0;
                    t.selectable = "single";
                    t.model = { id: "id" };
                    t.columnResize = function(n) { e.setColumnWidthCache(n, !0, v, s, p) };
                    e.formatColumns(t.columns, t.columns, s);
                    s.length > 0 && (s = []);
                    angular.forEach(t.columns, function(n) { s.push({ code: n.field || n.code, width: n.width }) });
                    t.excel = { allPages: !0 };
                    t.pageable = e.getPageable(n.pageSize || l);
                    h = r.kendoGrid(t).data("kendoGrid");
                    c = !1;
                    f = n.getCachedPageIndex() || 1;
                    h.dataSource.page(f) },
                w = function() { return [{ field: "name", title: "患者姓名", width: "120px", template: function(n) { var t = n.index; return '<ares-patient-namecard patient="patientList[' + t + '].patientHead" appt="patientList[' + t + ']" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "privateId", title: "病历号", width: "100px" }, { field: "sex", title: "性别", width: "60px" }, { field: "birth", title: "出生日期", width: "100px", code: "brithStr", attributes: { style: "padding: 0" } }, { field: "birth", title: "年龄", width: "50px", code: "ageStr", template: function(n) { var t = r("toAgeString"); return t(n.birth) } }, { field: "phoneNumberAndMask", title: "联系电话", width: "100px" }, { field: "firstVisit", title: "首诊时间", width: "100px" }, { field: "doctorName", title: "主治医生", width: "120px" }, { template: a.commandTemplate, title: "", width: "50px", code: "birthOption" }] },
                b = [{ text: "发短信", action: "sendMessage", icon: "glyphicon-comment" }],
                k = function(t) { return _.find(n.patientList, function(n) { return n.id == t }) },
                d = function(t, i, r) { n.$apply(function() { switch (i) {
                            case "sendMessage":
                                n.sendMessage(r, -1) } }) },
                g = function() { var i;
                    o.find("#birth").kendoDropDownList({ dataSource: [{ day: -1, name: "昨日" }, { day: 0, name: "今日" }, { day: 1, name: "明日" }, { day: 2, name: "自定义" }], dataTextField: "name", dataValueField: "day", select: function(i) { n.day = this.dataItem(i.item)[this.options.dataValueField];
                            t(function() { n.showDate = n.day == 2 ? !0 : !1 }) } });
                    i = o.find("#birth").data("kendoDropDownList");
                    i && i.value(n.day) },
                nt = function() { y() },
                tt = function() { n.day == 2 && (n.startDate = moment(new Date).format("MM-DD"), n.endDate = moment(new Date).add(7, "d").format("MM-DD")) },
                it = function() { var t = n.getSearchCriteria(),
                        i = { criteria: t, columns: h ? _.filter(h.columns, function(n) { return n.field }) : [] };
                    n.exportToExcel(i) };
            (function() { n.commands = b;
                n.onCommandClick = d;
                n.findPat = k;
                n.setDate = tt;
                c = !0;
                n.search = nt;
                n.exportExcel = it;
                y();
                g();
                n.$on("$destroy", function() { a.dispose() }) })() } } }]);
dashboardModule.directive("chargedPatientListView", ["$log", "$timeout", "$filter", "$window", "appNav", "dashboardSvc", "patientSvc", "practiceSvc", "enums", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "ChargedPatientCtrl", templateUrl: "/app/dashboard/views/charged-patient-list-view.html", scope: { officeId: "=" }, link: function(n, t) { var f = null,
                i = !1;
            t.find(".isHideData").hide();
            t.find("#chargedTodayInput").change(function() { t.find("#chargedTodayInput").val() == "自定义" ? t.find(".isHideData").show() : t.find(".isHideData").hide() });
            r.ChargedPatientCtrl_goToPatient = function(n) { n && u.goToPatient(n) };
            n.goToChargeHistory = function(n) { n.preventDefault(); var t = this.dataItem($(n.currentTarget).closest("tr"));
                t && t.patientId && u.goToCharge(t.patientId) }; var e = function() { o.listProviders().success(function(i) { var r = i,
                            u;
                        r.splice(0, 0, { id: -1, name: "全部" });
                        u = t.find("#payeeInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.doctorId = i.id } }) }) },
                s = function() { if (n.chargeOrderList) { i = !0; var r = t.find("#patientList");
                        f = r.kendoGrid({ dataSource: { data: n.chargeOrderList }, scrollable: !1, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "patientName", title: "姓名", width: "150px", template: '<a href="javascript:void(0)" onclick="ChargedPatientCtrl_goToPatient(#: patientId #)" >#: patientName #<\/a>' }, { field: "privateId", title: "病历号", width: "80px" }, { field: "doctorName", title: "医生", width: "60px" }, { field: "payeeName", title: "收银员", width: "60px" }, { field: "payTypeStr", title: "收款方式", width: "60px" }, { field: "actualPrice", title: "实收款", width: "60px", format: "{0:n}" }, { field: "payDateTimeStr", title: "收款时间", width: "120px" }, { command: [{ name: "收费历史", click: n.goToChargeHistory }], title: "", width: "120px" }] }).data("kendoGrid") } },
                h = function() { var i = t.find("#patientList"),
                        r = i.data("kendoGrid");
                    r.dataSource.data(n.chargeOrderList) };
            (function() { e();
                n.$watch("chargeOrderList", function() { n.updateCount();
                    i ? h() : s() });
                n.$on("$destroy", function() { delete r.ChargedPatientCtrl_goToPatient }) })() } } }]);
dashboardModule.directive("confirmationPatientView", ["$log", "$q", "$timeout", "$modal", "$window", "appNav", "appointmentSvc", "dataDicSvc", "permissionProvider", "practiceSvc", "dashboardSvc", "gridOptionUtil", "aresDialog", "localCache", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/confirmation-patient-view.html", scope: { officeId: "=" }, controller: "ConfirmationPatientCtrl", link: function(n, i) { var p = Ares.kendoGridUtil(u, n),
                w = v.getCache(v.keys.TomorrowApptColumnOption),
                e = w.loadObject();
            e = _.isArray(e) ? e : []; var g = null,
                nt = function() { return [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", headerAttributes: { "class": "rowNumber", style: "text-align:center;" }, attributes: { style: "padding: 0" } }, { title: "全选", headerTemplate: "<input name='selectAll' id='selectAll' type='checkbox' />", width: "50px", code: "selectAll", headerAttributes: { style: "text-align:center;" }, template: '<input type="checkbox" mobile="#: patient.mobile #" id="#: id #" patientId="#: patient.id #"/>' }, { field: "patient.name", title: "姓名", width: "150px", template: function() { return '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "patient.privateId", title: "病历号", isHidden: !1, width: "120px" }, { field: "patient.otherPrivateId", title: "其他病历号", isHidden: !0, width: "120px" }, { field: "patient.mobile", title: "手机", isHidden: !1, width: "110px" }, { field: "patient.brithStr", title: "出生日期", width: "130px", isHidden: !0, code: "brithStr", attributes: { style: "padding: 0" } }, { field: "patient.ageStr", title: "年龄", width: "100px", isHidden: !0, code: "ageStr", attributes: { style: "padding: 0" } }, { field: "startTimeLongStr", title: "预约时间", isHidden: !1, width: "110px" }, { field: "timeLengthInMinuteStr", title: "预约时长", isHidden: !1, width: "100px" }, { field: "doctorName", title: "预约医生", isHidden: !1, width: "100px" }, { field: "transactionNames", title: "预约项目", isHidden: !1, width: "100px", attributes: { "class": "td-class" } }, { field: "stateStr", title: "就诊状态", isHidden: !1, width: "100px" }, { field: "recordCreatedUserName", title: "创建人", isHidden: !1, width: "100px" }, { field: "confirmTypeStr", title: "确认方式", isHidden: !1, width: "100px" }, { field: "notes", title: "备注", isHidden: !1, width: "140px" }, { field: "checkInType", title: "就诊类型", isHidden: !0, hidden: !0, width: "130px" }, { field: "assistantName", title: "助手", isHidden: !0, hidden: !0, width: "80px" }, { field: "consultantName", title: "咨询师", isHidden: !0, hidden: !0, width: "100px" }, { field: "operatoryName", title: "诊室", isHidden: !0, hidden: !0, width: "80px" }, { field: "appointmentReminderTimesStr", title: "通知状态", isHidden: !1, width: "120px" }, { field: "outProcessStatus", title: "技加工状态", isHidden: !1, width: "120px" }, { field: "recordCreatedTimeStr", title: "创建时间", isHidden: !0, width: "120px" }, { field: "patient.sexStr", title: "性别", isHidden: !0, width: "120px" }, { field: "patient.ageStr", title: "年龄", isHidden: !0, width: "120px" }, { field: "patient.sourceTypeStr", title: "患者来源", isHidden: !0, width: "180px" }, { template: p.commandTemplate, title: "", width: "180px", code: "patient.command" }] },
                tt = function() { i.find("#confirmationList td input[type='checkbox']").each(function() { var r = this,
                            t = $(this).attr("mobile");
                        (t === "null" || t.trim() === "" || t == null) && $(r).attr("disabled", "disabled");
                        $(r).on("click", function() { var r = parseInt($(this).attr("id")),
                                u = parseInt($(this).attr("patientId")),
                                t;
                            this.checked ? (_.find(n.appts, { id: r }) === undefined && n.appts.push({ id: r, patientId: u }), i.find("#confirmationList td input[type='checkbox']:enabled").length === i.find("#confirmationList td input[type='checkbox']:checked").length && (t = i.find("#confirmationList th input[type='checkbox']")[0], t.checked = !0)) : (n.appts = _.reject(n.appts, { id: r }), t = i.find("#confirmationList th input[type='checkbox']")[0], t.checked = !1) }) });
                    i.find("#confirmationList th input[type='checkbox']").each(function() { var n = this,
                            t; if ($(n).attr("title", "全选"), t = $(n).attr("name"), t === "selectAll") $(n).on("click", function() { this.checked ? b(!0) : b(!1) }) }) },
                b = function(t) { i.find("#confirmationList td input[type='checkbox']").each(function() { var i = parseInt($(this).attr("id")),
                            r = $(this).attr("mobile"),
                            u = parseInt($(this).attr("patientId"));
                        r !== "null" && r.trim() !== "" && r != null && (this.checked = t);
                        this.checked ? _.find(n.appts, { id: i }) === undefined && n.appts.push({ id: i, patientId: u }) : n.appts = _.reject(n.appts, { id: i }) }) },
                it = function() { var r = t.defer(),
                        i = angular.copy(nt()); return l.loadColumnsOption(l.keys.confirmationPatientGridOption).then(function(t) { n.showColumns = t;
                        n.showColumns && n.showColumns.length != 0 || (n.showColumns = i);
                        l.formatColumns(i, n.showColumns, e);
                        e.length > 0 && (e = []);
                        angular.forEach(i, function(n) { e.push({ code: n.field || n.code, width: n.width }) });
                        r.resolve(i) }), r.promise },
                rt = function() { it().then(function(t) { var r = $(i).find("#confirmationList"),
                            u = r.offset().top,
                            f = $(window).height() - u - 50;
                        n.gridOption = { sortable: !0, scrollable: !0, resizable: !0, selectable: "single", columnMenu: !0, height: f, columns: t, columnShow: function(n) { var t = n.sender.columns;
                                l.updateColumnsOption(l.keys.confirmationPatientGridOption, t, k);
                                Ares.DockGridColMenuPos(n.sender) }, columnHide: function(n) { var t = n.sender.columns;
                                l.updateColumnsOption(l.keys.confirmationPatientGridOption, t, k);
                                Ares.DockGridColMenuPos(n.sender) }, columnMenuInit: function(n) { $(n.container).find(".k-menu-group > li.k-first").css("display", "none") }, columnResize: function(n) { l.setColumnWidthCache(n, !0, w, e, g) }, columnReorder: function(n) { Ares.DockGridColMenuPos(n.sender) }, dataBound: function(n) { Ares.DockGridColMenuPos(n.sender);
                                tt();
                                this.element.find(".k-grid-header .k-header-column-menu:eq(0)").css("float", "none") } } }) },
                k = function(t) { n.showColumns = t;
                    h() };
            i.find("#confirmationInput").change(function() { i.find("#confirmationInput").val() == "自定义" ? i.find(".isHideData").show() : i.find(".isHideData").hide() }); var ut = function() { var n = [{ text: "?确认或者取消确认?", action: "?confirm?", icon: "glyphicon-ok" }, { text: "修改预约", action: "update", icon: "glyphicon-pencil" }, ]; return s.isCancelApptAllowed && n.push({ text: "取消预约", action: "cancel", icon: "glyphicon-remove" }), s.isSmsAllowed && n.push({ text: "发短信", action: "sendMessage", icon: "glyphicon-comment" }), n },
                ft = function(n, t) { if (n.action === "?confirm?" && (t.isConfirmed ? (n.text = "取消确认", n.action = "unconfirm", n.icon = "glyphicon-repeat") : (n.text = "确认预约", n.action = "confirm", n.icon = "glyphicon-ok")), n.action === "update") { var i = s.isEditAllApptAllowed || t.recordCreatedUser == y.userId;
                        n.isDisabled = !i } },
                et, ot = function() { var i = t.defer(); return o.currentOfficeWorkProviderDic.load().then(function(t) { n.providers = t;
                        i.resolve(t) }), i.promise };
            ot().then(function() { et = function(t) { var i = _.find(n.providers, function(n) { return n.userID == t.recordCreatedUser }); return i ? i.name : "" } }); var pt = function(n) { return n.confirmType == 0 ? "诊所确认" : "自助确认" },
                st = function(t, i, r) { n.$apply(function() { var u = d(r),
                            e = u.patient; switch (i) {
                            case "goToPatient":
                                f.goToPatient(u.patient.id); break;
                            case "update":
                                n.updateAppt(u, function() { h(t, r) }); break;
                            case "confirm":
                                n.confirmAppt(u, function() { h(t, r) }); break;
                            case "unconfirm":
                                n.unconfirmAppt(u, function() { h(t, r) }); break;
                            case "cancel":
                                n.cancelAppt(u, function() { h(t, r) }); break;
                            case "sendMessage":
                                n.sendMessage(u.patient.id, r) } }) },
                h = function(t, r) { var f = $(i).find("#confirmationList"),
                        u = f.data("kendoGrid"); if (u.dataSource.data(n.unconfirmedAppts), r) { var e = u.dataSource,
                            o = e.get(r),
                            s = f.find("tbody>tr[data-uid=" + o.uid + "]");
                        u.select(s) } lt() },
                d = function(t) { return _.find(n.unconfirmedAppts, function(n) { return n.id == t }) },
                ht = function() { var u = $(i).find("#confirmationList"),
                        t = u.data("kendoGrid"),
                        r;
                    t && (r = { criteria: n.searchCriteria, columns: _.reject(t.columns, { title: "全选" }) }, c.exportAppointment(r)) },
                ct = function(t) { if (n.appts.length <= 0) { a.info("预约短信群发提醒", "请先选择预约"); return } if (n.appts.length > 500) { a.info("预约短信群发提醒", "您的预约已经超过500条"); return } var i = r.open({ animation: !0, backdrop: "static", template: "<short-message-appointment-edit-view><\/short-message-appointment-edit-view>", controller: "ShortMessageAppointmentEditCtrl", size: "lg", windowClass: "xl-dialog", resolve: { host: function() { return { batchId: null, action: t || null, appts: n.appts } } } }); return i.result },
                lt = function() { i.find("#selectAll")[0].checked = !1;
                    i.find("#confirmationList td input[type='checkbox']").each(function() { var t = parseInt($(this).attr("id"));
                        n.appts.indexOf(t) > -1 && (this.checked = !0) }) },
                at = function(t) { n.patientId = t ? t.id : null },
                vt = function() { n.patientId = null },
                yt = function(t) { var r, u, f = i.find("#confirmationInput").val(),
                        e, o; return _.isEmpty(t) ? f == "自定义" ? (r = moment(n.timeSpan.startDate), u = moment(n.timeSpan.endDate).add(1, "d")) : f == "1" ? (r = moment(Ares.today()).add(1, "d").toDate(), u = moment(r).add(1, "d").toDate()) : f == "2" ? (r = moment(Ares.today()).add(2, "d").toDate(), u = moment(r).add(1, "d").toDate()) : f == "3" && (r = moment(Ares.today()).add(3, "d").toDate(), u = moment(r).add(1, "d").toDate()) : (r = moment(t.startDate).toDate(), u = moment(t.endDate).add(1, "d").toDate()), e = n.doctorId > -1 ? n.doctorId : null, o = { officeId: n.officeId, doctorId: e, startTime: moment(r).format("YYYY-MM-DD"), endTime: moment(u).format("YYYY-MM-DD"), isCancelled: !1, isPending: !1, isConfirmationSearch: !0, department: n.department, pageIndex: n.criteria ? n.criteria.pageIndex : 1, pageSize: n.criteria ? n.criteria.pageSize : 1, isAsc: !0, patientId: n.patientId ? n.patientId : null }, o };
            (function() { n.appts = [];
                n.groupRemind = ct;
                n.exportExcel = ht;
                n.commands = ut();
                n.formatCommand = ft;
                n.onCommandClick = st;
                n.findAppt = d;
                n.onPatientChanged = at;
                n.onPatientCleared = vt;
                n.loadCriteria = yt;
                rt();
                n.$watch("unconfirmedAppts", function() { n.unconfirmedAppts && (n.updateCount(), h()) });
                n.$on("$destroy", function() { p.dispose() }) })() } } }]);
dashboardModule.directive("dashboardAdminOfficeAttendantView", ["$log", "$timeout", "$state", "appNav", "enums", "dashboardSvc", "patientSvc", "appointmentSvc", "aresDialog", "practiceSvc", function(n, t, i, r) { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-admin-office-attendant-view.html", scope: { officeId: "=" }, controller: "DashboardAdminOfficeAttendantCtrl", link: function(n) { var t = function(t) { n.currentState = t;
                r.switchState(t, {}) };
            (function() { n.switchState = t;
                n.listContentHeight = $(window).height() - 170 + "px"; var r = i.params.status || "dashBoard.todayAdminOfficeAppointment";
                i.current.name != r ? t(r) : n.currentState = i.current.name;
                n.$on("to-parent-current-state", function(t, i) { n.currentState = i }) })() } } }]);
dashboardModule.directive("dashboardTotalOfficeView", ["$log", "$timeout", "$state", "appNav", "enums", "dashboardSvc", "patientSvc", "appointmentSvc", "aresDialog", "practiceSvc", function() { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-admin-office-view.html", scope: { officeId: "=" }, controller: "DashboardAdminOfficeCtrl", link: function() {
            (function() {})() } } }]);
dashboardModule.directive("dashboardAssistantView", ["$log", function() { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-assistant-view.html", link: function() {
            (function() {})() } } }]);
dashboardModule.directive("dashboardConsultantView", ["$log", "dashboardSvc", "$q", "loginContext", function(n, t, i, r) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-consultant-view.html", link: function(n) { var t = function() { var i, t, u; if (r.dashboardRoleType != "咨询师" || r.roleDashboardConfig)
                    for (i = r.roleDashboardConfig.ConfigData[0].Items, t = 0; t < i.length; t++) u = i[t].Value.toLowerCase() == "true", i[t].Name == "todayCheck" ? n.isTodayCheckShow = u : n.isFollowupShow = u;
                else n.isTodayCheckShow = !0, n.isFollowupShow = !0 };
            (function() { n.isTodayCheckShow = !1;
                n.isFollowupShow = !1;
                t() })() } } }]);
dashboardModule.directive("dashboardDoctorView", ["$log", function() { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-doctor-view.html", controller: "DashboardDoctorCtrl", link: function() {
            (function() {})() } } }]);
dashboardModule.directive("dashboardFrontConsultantView", ["$log", "$timeout", "$state", "appNav", "enums", "dashboardSvc", "patientSvc", "appointmentSvc", "aresDialog", "practiceSvc", "loginContext", "$modal", function(n, t, i, r, u, f, e, o, s, h, c, l) { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-front-consultant-view.html", scope: { officeId: "=" }, controller: "DashboardFrontConsultantCtrl", link: function(n, t) { var u = function() { f.countConsultantAppointment().success(function(n) { e(n) }) },
                i = function(t) { f.getFollowUpPlans(t).success(function(i) { n.plans = i;
                        t && t != "" || p(i) }) },
                e = function(i) { var u = [],
                        f = [],
                        r = 60,
                        e;
                    i && i.length != 0 ? _.each(i, function(n) { n.planCount > 0 && n.planCount > r && (r = n.planCount);
                        n.actualCount > 0 && n.actualCount > r && (r = n.actualCount);
                        u.push(n.planCount);
                        f.push(n.actualCount) }) : (u = [0, 0, 0], f = [0, 0, 0]);
                    n.todayPlanCount = u[2];
                    n.todayActualCount = f[2];
                    e = $(t).find("#chart").kendoChart({ title: { text: "" }, legend: { position: "bottom" }, dataSource: { data: i }, series: [{ type: "area", field: "planCount", name: "预约应到", color: "#73c100", axis: "wind" }, { type: "area", field: "actualCount", name: "实际到店", color: "#007eff", axis: "rain" }], valueAxes: [{ name: "rain", color: "#007eff", min: 0, max: r, visible: !1 }, { name: "wind", color: "#73c100", min: 0, max: r, visible: !1 }, { name: "temp", min: 0, max: r }], categoryAxis: { categories: ["前天", "昨天", "今天"], axisCrossingValues: [32, 32, 0], justified: !0 }, tooltip: { visible: !0, format: "{0}", template: "#= dataItem.tooltip #" } }) },
                o = { providerId: c.providerId, sumType: "今日" },
                s = [new DashboardBlock("新增预约", null, "icon-plus bg-blue", 10), new DashboardBlock("新增回访计划", null, "icon-layers bg-green", 20), new DashboardBlock("新增咨询单", null, "icon-docs bg-purple", 30), new DashboardBlock("公众号新增粉丝", null, "icon-emoticon-smile bg-pink", 40)],
                a = function() { var n = l.open({ animation: !0, backdrop: "static", template: "<my-achievements-setting-view><\/my-achievements-setting-view>", controller: "MyAchievementsSettingCtrl", windowClass: "private-id-rule-edit-dialog", size: "lg", resolve: { host: function() { return null } } });
                    n.result.then(function(n) { n && r() }) },
                v = function() { f.getWebPhoneConsultantSumByFilter(o).success(function(t) { var i = [];
                        angular.forEach(t, function(n) { var r = _.find(s, { type: n.itemName }),
                                t;
                            r && (t = _.clone(r), t.value = n.itemValue, t.text = n.itemName, i.push(t)) });
                        i = _.sortBy(i, "showOrder");
                        n.summaryBlocks = i }) },
                r = function() { h.getSystemConfigByType("Dashboard").success(function(t) { var i = _.find(t, { configName: "protectionAmount" }),
                            r = !1;
                        i && (r = i.configValue.toLowerCase() == "true");
                        n.isProtectedMode = r }) },
                y = function(n, r) { $(t).find(".selected-td").removeClass("selected-td");
                    $(n.toElement).hasClass("selected-td") || $(n.toElement).addClass("selected-td");
                    i(r) },
                p = function(t) { n.notFollowupCount = _.filter(t, { status: "待回访" }).length;
                    n.hasFollowupCount = _.filter(t, { status: "已回访" }).length;
                    n.followupCancelledCount = _.filter(t, { status: "已取消" }).length };
            (function() { n.isProtectedMode = !0;
                n.selected = y;
                n.showMyAchievementsSettingDialog = a;
                r();
                v();
                u();
                i("") })() } } }]);
dashboardModule.directive("dashboardFrontView", ["$log", "$timeout", "$state", "localCache", "appNav", "enums", "moduleOptionProvider", "permissionProvider", "patientSvc", "newReportGuideUtil", "aresDialog", "practiceSvc", "officeOptionSvc", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-front-view.html", scope: { officeId: "=" }, controller: "DashboardFrontCtrl", link: function(n) { var y = r.getCache(r.keys.IsDashboardNewFinanceReportEnabled),
                s = r.getCache(r.keys.IsDashboardNewFinanceReportEnabled + "_" + v.officeId + "_" + v.userId),
                c = function(t) { t && (n.currentState = t, u.switchState(t, {})) },
                l = function() { t(function() { n.isDashboardNewFinanceReportEnabled = !n.isDashboardNewFinanceReportEnabled;
                        s.saveValue(n.isDashboardNewFinanceReportEnabled) }) },
                p = function() { var t = n.listBlocks[0].stateName;
                    i.current.name && i.current.name != "dashBoard" && (t = i.current.name);
                    i.params.status && (t = i.params.status);
                    c(t) },
                w = function() { u.goToState("setting.charge.paymentType") };
            (function() { var t, i;
                n.switchState = c;
                n.initView = p;
                n.switchVersion = l;
                n.listContentHeight = $(window).height() - 150 + "px";
                n.listContentHeight2 = $(window).height() - 160 + "px";
                n.$on("to-parent-current-state", function(t, i) { n.currentState = i });
                t = s.loadValue();
                t === null && (t = y.loadValue());
                n.isForceNewReportEnabled = e.isForceNewReportEnabled();
                n.isAllowConfigPaymentType = o.isAllowed("setting.paymentTypeUpgrade");
                n.navToPaymentTypeConfig = w;
                i = [a.optionKeys.PaymentTypeUpgradeStatus, a.optionKeys.IsNewPaymentTypeEnabled, ];
                a.getOfficeOptions(i).then(function(i) { if (i && i.length >= 1) { let r = i[0];
                        n.isShowNewAccountCheck = i[1] == 1 && (r == f.PaymentTypeUpgradeStatus.Finished || r == f.PaymentTypeUpgradeStatus.InitUpgraded);
                        n.isDashboardNewFinanceReportEnabled = n.isShowNewAccountCheck && (t == "true" || r == f.PaymentTypeUpgradeStatus.InitUpgraded);
                        n.isOnlyShowNewReport = n.isForceNewReportEnabled || n.isShowNewAccountCheck && r == f.PaymentTypeUpgradeStatus.InitUpgraded;
                        n.isDashboardNewFinanceReportEnabled || h.isForcingToNewReportPromise().then(function(n) { n && l() }) } }) })() } } }]);
patientModule.directive("dashboardHealthInsuranceUploadView", ["$q", "$timeout", "$modal", "$state", "healthInsuranceSvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/dashboard-health-insurance-upload-view.html", link: function(t, i) { var r = function() { var t = n.defer(); return u.getServiceConfig().then(function(n) { var i = n.data;
                        t.resolve(i) }), t.promise },
                f = function() { r().then(function(n) { Ares.Loader.loadJs(n.baseUrl + "../js/plugin.js", function() { var i = t.todoItem,
                                r = { containerId: "healthInsuranceUploadContainer", processId: i.processId, apiServer: n.baseUrl, url: "/insurance/front/insurance-certificateUpload", token: n.accessToken };
                            InSurance(r);
                            e() }) }) },
                e = function() { var n = i.find("#healthInsuranceUploadContainer iframe");
                    n && n.height(500) };
            (function() { f() })() } } }]);
dashboardModule.directive("dashboardHealthInsuranceView", ["$log", "$modal", "healthInsuranceSvc", function(n, t, i) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-health-insurance-view.html", link: function(n) { var r = function() { i.getTodoList().then(function(t) { n.todoList = t.data;
                        n.hasTodo = t.data && t.data.length > 0 }) },
                u = function(n) { f(n).then(function() { r() }) },
                f = function(n) { return t.open({ animation: !0, backdrop: "static", template: "<dashboard-health-insurance-upload-view><\/dashboard-health-insurance-upload-view>", controller: "DashboardHealthInsuranceUploadCtrl", windowClass: "upload-window", size: "md", resolve: { host: function() { return { todoItem: n } } } }).result };
            (function() { n.hasTodo = !1;
                n.uploadInsuranceOrder = u;
                r() })() } } }]);
dashboardModule.directive("dashboardNetConsultantView", ["$log", function() { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-net-consultant-view.html", link: function() {
            (function() {})() } } }]);
dashboardModule.directive("dashboardTodayAccountCheckView", ["$log", "$window", "$timeout", "$q", "gridOptionUtil", "$modal", "reportSvc", "userOptionSvc", function(n, t, i, r, u, f, e, o) { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-today-account-check-view.html", controller: "DashboardTodayAccountCheckCtrl", link: function(n, s) { var l = [{ field: "feeType", title: "类型", width: "250px", hidden: !1 }, { field: "billNo", title: "单据号", width: "250px", hidden: !1 }, { field: "patientName", title: "患者姓名", width: "250px", hidden: !1 }, { field: "privateId", title: "病历号", width: "250px", hidden: !1 }, { field: "checkInTime", title: "挂号时间", width: "250px", hidden: !1 }, { field: "payDateTime", title: "收费时间", width: "250px", hidden: !1 }, { field: "payeeJob", title: "收款人岗位", width: "250px", hidden: !1 }, { field: "payee", title: "收款人", width: "250px", hidden: !1 }, { field: "recordCreatedUserJob", title: "开单人岗位", width: "250px", hidden: !1 }, { field: "recordCreatedUserName", title: "开单人", width: "250px", hidden: !1 }, { field: "actualPrice", title: "实收金额", width: "250px", hidden: !1 }, { field: "overdueCharge", title: "欠费", width: "250px", hidden: !1 }, { field: "giftAmount", title: "优惠总计", width: "250px", hidden: !1 }, { field: "comments", title: "备注", width: "250px", hidden: !1 }],
                a = { scrollButtons: { enable: !1 }, autoHideScrollbar: !0, scrollInertia: 150, advanced: { updateOnContentResize: !0 } },
                st = function() { h(); var n = angular.element(t);
                    s.find(".list-tabel-wrap .table-main").mCustomScrollbar(a);
                    n.on("resize", function() { h() }) },
                p = function() { $(s).find(".table-main-content .ares-checkbox").each(function() { $(this).bind("click", function() { var n = $(this).attr("data-chargeOrder-id");
                            w(n) }) }) },
                w = function(t) { t && _.indexOf(n.selectedChargeOrderIds, t) < 0 ? n.selectedChargeOrderIds.push(t) : n.selectedChargeOrderIds.splice(0, 1, t) },
                h = function() { var i = angular.element(t).height(),
                        r = i - 365,
                        n = s.find(".list-tabel-wrap .table-main");
                    n.height(r);
                    n.data("mCustomScrollbarIndex") ? n.mCustomScrollbar("update") : n.mCustomScrollbar(a);
                    p();
                    g() },
                c = function(t, r) { r || (n.isExpandAll = !n.isExpandAll);
                    b(t);
                    i(function() { h() }) },
                b = function(t) { var i = t.items;
                    i && i.length > 0 && angular.forEach(i, function(t) { t.isShowDetails = n.isExpandAll }) },
                k = function(n) { var t = window.event ? n.keyCode : n.which;
                    t == 13 && v() },
                d = function() { n.setCriteria(n.searchCriteria); var t = { criteria: n.searchCriteria, columns: l };
                    e.exportAccountCheck(t) },
                v = function(t) { n.search().then(function() { n.isExpandAll = !1;
                        t = t ? t : 0;
                        c(n.chargeAccountCheckResult, t) }) },
                ht = angular.element(t).height() - 230,
                g = function() { i(function() { s.find(".list-tabel-wrap").find('[data-toggle="tooltip"]').tooltip() }) },
                nt = function() { n.search(!0).then(function() { c(n.chargeAccountCheckResult, 1) }) },
                tt = function() { var n = "",
                        i = s.find('input[name="feeTypes"]:checked'),
                        t; if (i.length > 0) { for (t = 0; t < i.length; t++) n = n + i[t].value + ",";
                        n = n.substring(0, n.length - 1) } return n || "-1" },
                it = function() { var t = r.defer(); return o.getUserOption(u.keys.chargeAccountCheckGridOption).then(function(i) { n.showColumns = i != null ? i : "^";
                        t.resolve(!0) }), t.promise },
                rt = function(t) { var i = n.showColumns.split(",");
                    i = _.filter(i, function(n) { return n.indexOf("undefined") === -1 });
                    u.formatColumns(t, i);
                    n.gridColumns = t },
                ut = function() { var t = n.gridColumns,
                        i = u.keys.chargeAccountCheckGridOption,
                        r = f.open({ animation: !0, backdrop: "static", template: "<config-columns-dialog-view><\/config-columns-dialog-view>", controller: "ConfigColumsDialogCtrl", backdropClass: "ares-modal-backdrop", resolve: { host: function() { return { gridColumns: t, optionkey: i } } } });
                    r.result.then(function() { y() }) },
                y = function() { it().then(function() { rt(l) }) },
                ft = function(n) { n.isShowDetails = !n.isShowDetails;
                    i(function() { h() }) },
                et = function(n) { n.isChecked = !n.isChecked },
                ot = function() { introJs().setOptions({ prevLabel: "上一步", nextLabel: "下一步", skipLabel: "跳过", doneLabel: "结束" }).oncomplete(function() {}).onexit(function() {}).start() };
            (function() { n.selectedChargeOrderIds = [];
                n.onEnter = k;
                n.onChangeChargeOrder = et;
                n.getFeeTypes = tt;
                n.searchAndOpen = v;
                n.exportExcel = d;
                n.configColumn = ut;
                n.pageSearch = nt;
                n.expandAllChange = c;
                n.initTableView = h;
                n.currentChargeOrderChange = ft;
                y();
                n.init();
                h();
                i(function() { ot() }) })() } } }]);
dashboardModule.directive("dashboardView", ["$log", "$timeout", "$state", "enums", "dashboardSvc", "moduleOptionProvider", "loginContext", function(n, t, i, r, u, f) { return { restrict: "E", templateUrl: "/app/dashboard/views/dashboard-view.html", scope: { officeId: "=" }, controller: "DashboardCtrl", link: function(n) { var t = function(t) { n.type = t;
                    localStorage.setItem("onlineConsultDashboardType", t) },
                i = function() { if (f.isNewOnlineConsultantEnabled()) { var t = localStorage.getItem("onlineConsultDashboardType");
                        type = t ? t : "new" } else type = "old";
                    n.type = type };
            (function() { n.groupType = t;
                i() })() } } }]);
dashboardModule.directive("dashboardYibaoInsuranceBillCheckView", ["$log", "$compile", "$timeout", "$window", "yibaoGatewaySvc", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/dashboard-yibao-insurance-bill-check-view.html", link: function(n, t) { var f = function() { var n = t.find("#yibaoAccountFrame"),
                    i = t.offset().top,
                    u = r.innerHeight - i - 43;
                n.css("height", u) };
            (function() { i(function() { f() });
                u.getAccountCheckUrl().success(function(t) { n.yibaoAccountUrl = t }) })() } } }]);
dashboardModule.directive("followupPatientListView", ["$log", "$timeout", "$window", "$q", "shortMessageUtil", "followupUtil", "gridOptionUtil", "sessionCache", "officeOptionSvc", "dataDicSvc", "patientUtil", "permissionProvider", "patientSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a) { "use strict"; return { restrict: "E", replace: !0, controller: "FollowupPatientCtrl", templateUrl: "/app/dashboard/views/followup-patient-list-view.html", scope: { officeId: "=" }, link: function(n, v) { var k = Ares.kendoGridUtil(i, n),
                y = 5,
                p = o.getCache(o.keys.PageSize);
            v.find(".isHideData").hide(); var d = function() { var n; if (p && (n = p.loadObject(), y = n.pageSize), !y) { var t = $(window).height(),
                            i = t - 240,
                            r = i - 81;
                        y = Math.max(5, parseInt(r / 40)) } },
                yt = function() { t(function() { var n = v.find("#followupList").data("kendoGrid"),
                            t;
                        n && (t = n.pager, t && t.element.bind("change", function() { var t = n.dataSource.pageSize();
                            p && p.saveObject({ pageSize: t }) })) }, 1e3) },
                g = function() { var t = this,
                        n;
                    $(v).find("#followupList table tbody tr").each(function(n, i) { var r = t.dataItem(i);
                        r.status != "待计划" && v.find(i).find('button[data-action="goToFollow"]').remove();
                        r.status == "已取消" && v.find(i).find('button[data-action="view"]').remove() });
                    n = this.items();
                    $(n).each(function() { var n = v.find("#followupList").data("kendoGrid"),
                            t = $(this).index() + 1 + n.dataSource.pageSize() * (n.dataSource.page() - 1),
                            i = $(this).find(".row-number");
                        $(i).html(t) }) },
                nt = function() { var t = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "50px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientName", title: "姓名", width: "120px", template: function() { return '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "privateId", title: "病历号", width: "100px" }, { field: "mobileAndPhoneNumberMark", title: "联系电话", width: "100px" }, { field: "doctorName", title: "随访医生", width: "100px" }, { field: "otherProviderName", title: "随访人员", width: "100px" }, { field: "visitContent", title: "随访内容", width: "170px" }, { field: "visitResult", title: "随访结果", width: "150px" }, { field: "visitDateTime", title: "计划时间", width: "110px" }, { field: "executeTime", title: "随访时间", width: "120px" }, { field: "status", title: "随访状态", width: "100px" }, { template: k.commandTemplate, title: "", width: "260px", attributes: { "class": "followup-command-container" } }]; return n.isEnableConsultantDiagnose && t.splice(6, 0, { field: "consultantName", title: "咨询师", width: "100px" }), t },
                tt = function() { n.gridOption = { dataBound: g, pageable: e.getPageable(y), scrollable: !1, sortable: !0, resizable: !0, reorderable: !0, selectable: "single", model: { id: "id" }, columns: nt() } },
                w = [{ text: "执行", action: "goToFollow", icon: null }, { text: "修改", action: "view", icon: null }, { text: "短信", action: "sendMessage", icon: null }, { text: "日志", action: "changeLog", icon: null }, ];
            l.isDeleteFollowupAllowed && w.push({ text: "删除", action: "delete", icon: null }); var it = function(t) { return _.find(n.followupPatList, function(n) { return n.id == t }) },
                b = function(n, t) { var i = r.defer(); return r.all([a.getFollowup(n), a.getPatientsHeadInfo([t])]).then(function(n) { var t = n[0].data,
                            r = n[1].data[0];
                        i.resolve([t, r]) }), i.promise },
                rt = function(t) { c.checkFollowupPrivilege(t, "edit").then(function() { b(t.id, t.patientId).then(function(t) { f.openEditFollowupDialog(t[0], t[1]).then(function(t) { t && n.refresh() }) }) }) },
                ut = function(t) { c.checkFollowupPrivilege(t, "view").then(function() { b(t.id, t.patientId).then(function(t) { f.openExecuteFollowupDialog(t[0], t[1]).then(function(t) { t && n.refresh() }) }) }) },
                ft = function(t, i, r) { n.$apply(function() { var t = it(r); switch (i) {
                            case "sendMessage":
                                u.sendMessage(t.patientId, 0); break;
                            case "goToFollow":
                                ut(t); break;
                            case "view":
                                rt(t); break;
                            case "delete":
                                c.checkFollowupPrivilege(t, "delete").then(function() { n.deleteFollowup(r) }); break;
                            case "changeLog":
                                n.showFollowupAuditLog(r) } }) },
                et = function() { n.isShowFollowupDialog = !1 },
                ot = function() { var t = v.find("#followupList").data("kendoGrid");
                    t && t.dataSource.data(n.filterFollowups) },
                st = function() { var i = v.find("#daySelectBtn");
                    i.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectBtn").datepicker("hide");
                        n.isInitialized ? n.isInitialized = !1 : t(function() { n.date = i.date; var t = n.loadSearchCriteria();
                            n.refresh(t) }, 100) });
                    i.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                ht = function() { $("#daySelectBtn").datepicker("update", moment(n.date).format("YYYY-MM-DD")) },
                ct = function() { h.doctorDic.loadActive().then(function(t) { v.find("#doctor").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "id", select: function(t) { n.searchCriteria.doctorId = this.dataItem(t.item)[this.options.dataValueField] || null }, value: n.searchCriteria.doctorId || null }) }) },
                lt = function() { h.currentOfficeWorkProviderDic.loadActive().then(function(t) { v.find("#otherProvider").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "id", select: function(t) { n.searchCriteria.otherProviderId = this.dataItem(t.item)[this.options.dataValueField] || null }, value: n.searchCriteria.otherProviderId || null }) }) },
                at = function() { h.consultantDic.loadActive().then(function(t) { v.find("#consultant").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "id", select: function(t) { n.searchCriteria.consultantId = this.dataItem(t.item)[this.options.dataValueField] || null }, value: n.searchCriteria.consultantId || null }) }) },
                vt = function() { s.getOfficeOption(s.optionKeys.EnableConsultantDiagnose).then(function(t) { n.isEnableConsultantDiagnose = t;
                        d();
                        tt();
                        ct();
                        lt();
                        at() }) };
            (function() { n.commands = w;
                n.onCommandClick = ft;
                n.refreshDate = ht;
                n.hideFollowupDialog = et;
                st();
                vt();
                n.$watch("filterFollowups", function() { n.updateCount();
                    ot() }) })() } } }]);
dashboardModule.directive("myAchievementsSettingView", ["$log", "$timeout", "$window", function(n, t) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/my-achievements-setting-view.html", link: function(n, i) { var r, u = function() { var t = this;
                    $(i).find("#myAchivementList input[type='checkbox']").each(function(t) { var i = this;
                        $(i).attr("index", t);
                        $(i).attr("checked", n.myAchivement[t].configValue);
                        $(i).attr("checkValue", n.myAchivement[t].configValue);
                        $(i).bind("click", function() { $(this).attr("checkValue", $(this).attr("checkValue") == "true" ? "false" : "true"); var t = $(this).attr("index");
                            n.myAchivement[t].configValue = $(this).attr("checkValue") == "true" ? !0 : !1;
                            n.hasChanged = !0 }) }) },
                f = function() { if (n.myAchivement) { var f = $(i).find("#myAchivementList");
                        r = f.kendoGrid({ dataSource: n.myAchivement, columns: [{ field: "是否显示", width: "50px", template: "<input  type='checkbox' />" }, { field: "coments", title: "名称", width: "140px" }], scrollable: !1, sortable: !1, selectable: "single", dataBound: u, change: function() { var i = this.dataItem(this.select());
                                i.id && t(function() { n.selectedItem = i ? i : null }) } }).data("kendoGrid") } },
                e = function() { r ? (r.dataSource.data(n.myAchivement), o()) : f() },
                o = function() { if (n.selectedItem) { var i = r.dataSource,
                            u = i.get(n.selectedItem.id),
                            t = r.element.find("tbody>tr[data-uid=" + u.uid + "]");
                        t && r.select(t) } };
            (function() { n.$watch("myAchivement", function() { n.myAchivement && e() }) })();
            t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 5) } } }]);
dashboardModule.directive("overduePatientListView", ["$log", "$timeout", "$filter", "$window", "appNav", "dashboardSvc", "enums", "permissionProvider", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "OverduePatientCtrl", templateUrl: "/app/dashboard/views/overdue-patient-list-view.html", scope: { officeId: "=" }, link: function(n, t) { var f = Ares.kendoGridUtil(r, n),
                e = !1,
                i = null,
                c = function() { var i, r, u;
                    n.overduePatList && (e = !0, i = t.find("#patientList"), i.kendoGrid({ dataSource: { data: n.overduePatList }, scrollable: !1, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "name", title: "姓名", width: "150px", template: f.patientNameTemplate }, { field: "sexStr", title: "性别", width: "60px" }, { field: "mobile", title: "手机号", width: "60px" }, { field: "overdue", title: "欠费金额", width: "60px" }, { template: f.commandTemplate, title: "", width: "180px" }] }), r = i.data("kendoGrid"), u = [{ field: "startTimeStr", dir: "asc" }], r.dataSource.sort(u)) },
                s = [];
            o.isSmsAllowed && s.push({ text: "发短信", action: "sendMessage", icon: "glyphicon-comment" }); var h = function(t) { return _.find(n.overduePatList, function(n) { return n.id == t }) },
                l = function(t, i, r) { n.$apply(function() { var t = h(r); switch (i) {
                            case "goToPatient":
                                u.goToPatient(t.id); break;
                            case "sendMessage":
                                n.sendMessage(t.id, 0) } }) },
                a = function() { var t = $("#patientList"),
                        i = t.data("kendoGrid");
                    i.dataSource.data(n.overduePatList) },
                v = function() { i = $state.current;
                    i.onActivated = refresh };
            (function() { n.commands = s;
                n.onCommandClick = l;
                n.findPat = h;
                n.$watch("overduePatList", function() { n.updateCount();
                    e ? a() : c() });
                n.$on("$destroy", function() { f.dispose();
                    i && (i.onActivated = null) }) })() } } }]);
dashboardModule.directive("stockExpirationRemindView", ["$log", "$rootScope", "$timeout", "$modal", "appNavItemProvider", "$state", "dataDicSvc", "warehouseUtil", "eventAggregator", "appNav", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; return { templateUrl: "/app/dashboard/views/stock-expiration-remind-view.html", controller: "StockExpirationRemindCtrl", link: function(n, t) { var r = function() { e.warehouseDic.loadActive().then(function(i) { var r, f, u;
                        i = o.filterWarehouses(i);
                        r = o.getDefaultWarehouse(i);
                        f = r ? r.id : null;
                        i.splice(0, 0, { id: 0, name: "全部仓库" });
                        t.find("#warehouse").kendoDropDownList({ dataSource: i, dataTextField: "name", dataValueField: "id", select: function(t) { n.criteria.warehouseId = this.dataItem(t.item)[this.options.dataValueField] || null;
                                n.query() } });
                        n.isInventoryValidityWarnEnabled || (u = t.find("#warehouse").data("kendoDropDownList"), u.enable(!1)) }) },
                u = function() { h.switchState("officeSettings.supplyChain") };
            (function() { n.initWareHouseDropdown = r;
                n.switchState = u;
                n.$watch("expiratingInventoryList", function() { i(function() { var i = t.find("#stockStatusList"),
                            r = t.find("#stockStatusList").offset().top,
                            u = $(window).height() - r - 60;
                        n.expiratingInventoryList.length >= 9 ? i.css("height", u) : i.css("height", "333px") });
                    n.updateCount() }) })() } } }]);
dashboardModule.directive("todayAccountCheckHome", ["$log", "$timeout", "$state", "enums", "dashboardSvc", "moduleOptionProvider", "loginContext", function() { return { restrict: "E", templateUrl: "/app/dashboard/views/today-account-check-home.html", scope: !0, controller: "DashboardCtrl", link: function() {
            (function() {})() } } }]);
dashboardModule.directive("todayAdminOfficeRevisitListView", ["$log", "$timeout", "$filter", "$window", "appNav", "officeSvc", "apptUtil", function(n, t, i, r, u, f) { "use strict"; return { restrict: "E", replace: !0, controller: "TodayAdminOfficeRevisitListCtrl", templateUrl: "/app/dashboard/views/today-admin-office-revisit-list-view.html", scope: { officeId: "=" }, link: function(n, i) { var b = Ares.kendoGridUtil(r, n),
                e = !1,
                s = function() { var t, i;
                    n.searchText || (n.filteredRevisits = n.adminOfficeRevisits);
                    n.filteredRevisits && (t = [{ text: "修改", exec: n.updateRevisit, canExec: n.canEdit }, { text: "取消", exec: n.cancelRevisit, canExec: n.canCancel }, ], e = !0, i = $(window).height() - 280, n.gridOption = { resizable: !0, model: { id: "id" }, columns: [], height: i }, n.gridOption.columns.push({ field: "patient.nameCode", title: "姓名", width: "102px", sortable: !1, index: 1, code: "patientName", attributes: { "class": "patient-td", style: "padding: 0" }, template: function() { return '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="noIcon" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "mobile", title: "联系电话", width: "100px" }, { field: "abbreviation", title: "门店", width: "130px" }, { field: "recordCreatedTimeStr", title: "创建日期", width: "120px" }, { field: "revisitTypeStr", title: "回访类型", width: "90px" }, { field: "transactionNames", title: "回访项目", width: "110px" }, { field: "revisitStateStr", title: "回访状态", width: "73px" }, { field: "revisitMethodStr", title: "回访方式", width: "73px" }, { title: "操作", index: 200, code: "apptOperation1", isHidden: !1, width: "130px", template: function(n) { return n.actionCommands || (n.actionCommands = t), '<ares-command-group commands="::dataItem.actionCommands" tag="::dataItem"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:110px;padding: 0" } }), o()) },
                h = function(t, i, r) { n.$apply(function() { var n = findFollowupPatient(r); switch (i) {
                            case "goToPatient":
                                u.goToPatient(n.patientId) } }) },
                c = function() { v();
                    a(); var r = i.find("#daySelectAdminOfficeBtn");
                    r.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectAdminOfficeBtn").datepicker("hide");
                        n.isInitialized ? n.isInitialize = !1 : t(function() { n.date = i.date;
                            n.loadRevisits() }, 100) });
                    r.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                l = function() { $("#daySelectAdminOfficeBtn").datepicker("update", moment(n.date).format("YYYY-MM-DD")) },
                a = function() { f.list().success(function(t) { var r = t,
                            u;
                        r.splice(0, 0, { id: -1, abbreviation: "全部" });
                        u = i.find("#officeInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "abbreviation", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.currentOfficeId = i.id;
                                n.loadRevisits() } }) }) },
                v = function() { var t = i.find("#revisitTypeInput");
                    t.kendoDropDownList({ dataSource: [{ typeValue: -1, typeName: "请选择类型" }, { typeValue: 1, typeName: "预约未到" }, { typeValue: 2, typeName: "沉睡客户" }, { typeValue: 3, typeName: "未消费回访" }, { typeValue: 4, typeName: "消费后回访" }], placeholder: "", dataTextField: "typeName", dataValueField: "typeValue", select: function(t) { var i = this.dataItem(t.item.index());
                            n.revisitType = i.typeValue;
                            n.loadRevisits() } }) },
                o = function() { var r = i.find("#adminOfficeRevisitList"),
                        t = r.data("kendoGrid");
                    t && t.dataSource.data(n.filteredRevisits) },
                y = function(t) { n.revisitStatus = t;
                    n.loadRevisits() },
                p = function() { n.revisitId = null;
                    n.patientId = null;
                    n.isShowRevisitEditDialog = !0 },
                w = function() { n.isShowRevisitEditDialog = !1 };
            (function() { n.searchText = null;
                n.revisitStatus = -1;
                n.currentOfficeId = -1;
                n.revisitType = 0;
                n.onCommandClick = h;
                n.refreshDate = l;
                n.switchState = y;
                c();
                n.addRevisit = p;
                n.hideRevisitEditDialog = w;
                n.isShowRevisitEditDialog = !1;
                n.$watch("filteredRevisits", function() { e ? o() : n.filteredRevisits && s() }) })() } } }]);
dashboardModule.directive("todayCheckedInPatientListView", ["$log", "$timeout", "$modal", "$interval", "$filter", "$window", "$state", "enums", "apptUtil", "eventAggregator", "localCache", "permissionProvider", "aresDialog", "loginContext", "officeOptionSvc", "gridOptionUtil", "followupUtil", "practiceSvc", "sessionCache", "dataDicSvc", "aresSlidePanel", "appNav", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt) { "use strict"; return { restrict: "E", replace: !0, controller: "TodayCheckedInPatientCtrl", templateUrl: "/app/dashboard/views/today-checked-in-patient-list-view.html", scope: { officeId: "=" }, link: function(n, r) { var rt = k.getCache(k.keys.PageSize),
                lt = c.getCache(c.keys.TodayCheckedInPatientColumnOption),
                ut = c.getCache(c.keys.TodayCheckedInPatientSortFields),
                tt = lt.loadObject(),
                d = ut.loadObject();
            tt = _.isArray(tt) ? tt : []; var ft = null,
                bt = null,
                it = null,
                f = null,
                et = 5,
                ht = null,
                kt = function() { var i, f, u;
                    ni();
                    i = this;
                    f = [];
                    s.formatApptGrid(this, function(n, t) { var u = i.dataItem(t),
                            f;
                        u && (f = r.find(t).find("td.appointment-status-td"), f.attr("id", "apptState" + u.id)) }); var e = i.element,
                        t = e.find(".k-grid-header"),
                        o = t.find(".k-header-column-menu:gt(0)").length;
                    o > 0 && (t.find(".k-header-column-menu").hide(), t.find(".rowNumber").find(".k-header-column-menu").show(), t.find(".k-header-column-menu:eq(0)").css("float", "none"), t.find(".k-header:gt(0)").each(function(n, t) { var i = $(t).find("a");
                        i.css("margin-right", "0") }));
                    u = this.items();
                    $(u).each(function() { var n = r.find("#apptList").data("kendoGrid"),
                            t = $(this).index() + 1 + n.dataSource.pageSize() * (n.dataSource.page() - 1),
                            i = $(this).find(".row-number");
                        $(i).html(t) });
                    n.refreshedTime = Ares.timestamp() },
                dt = function(t) { n.showColumns = t },
                gt = function(t, i, r) { var a = [{ text: "挂号", icon: "glyphicon-log-in", exec: n.checkInAppt, canExec: s.canCheckIn }, { text: "开始治疗", icon: "glyphicon-saved", exec: n.seatAppt, canExec: s.canSeat }, { text: "完成治疗", icon: "glyphicon-ok", exec: n.completeAppt, canExec: s.canComplete }, { text: "已离开", icon: "glyphicon-log-out", exec: n.leftAppt, canExec: s.canLeft }, { text: "回退", icon: "icon-action-undo", exec: n.undo, canExec: s.canUndo, notDefault: !0 }, ],
                        y, k, h, e, c, o;
                    i || (a = _.filter(a, function(n) { return n.text != "咨询" })); var v = [{ text: "修改预约", icon: "glyphicon-pencil", exec: n.editApptOrEditCheckIn, canExec: s.canEdit }, { text: "创建新预约", icon: "glyphicon-plus", exec: n.createAppt }, ],
                        w = [{ text: "打印挂号单", icon: "glyphicon-print", exec: n.printAppt, canExec: s.canPrintCheckin }],
                        b = [{ text: "收费", icon: "glyphicon-usd", exec: n.createChargeOrder, canExec: s.canCharge }];
                    l.isCancelApptAllowed && v.splice(1, 0, { text: "取消预约", icon: "glyphicon-remove", exec: n.cancelAppt, canExec: s.canCancel });
                    y = [{ text: "发消息", icon: "glyphicon-comment", exec: n.sendMessage }];
                    n.gridOption = { pageable: p.getPageable(et), sortable: !0, resizable: !0, reorderable: !0, height: $(window).height() - 240, selectable: "single", change: function() { it = this.dataItem(this.select()).id }, dataBound: kt, columnMenu: !0, columnShow: function(n) { ot(n) }, columnHide: function(n) { ot(n) }, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                            n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                            t.find("li").each(function(n, t) { var i = $(t).text();
                                (i == "姓名" || i == " ") && $(t).remove() }) }, columnReorder: function(n) { ot(n) }, columnResize: function(n) { ot(n, !0) }, model: { id: "id" }, columns: [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", height: "auto", template: "<span class='row-number'><\/span>", headerAttributes: { "class": "rowNumber" }, attributes: { style: "padding: 0" } }, { field: "patient.nameCode", title: "姓名", width: "120px", index: 2, code: "patientName", attributes: { "class": "patient-td", style: "padding: 0;min-width:120px" }, template: function(n) { return n.patientHead && n.patientHead.tags && n.patientHead.tags.length > 0 && angular.forEach(n.patientHead.tags, function(n) { n.textColor = n.itemValue ? Ares.getForegroundColor(n.itemValue) : Ares.getForegroundColor("#fff") }), '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "mobiles[0].mobile", title: "手机", width: "200px", isHidden: !0, index: 3, code: "mobileStr", template: function(n) { var t = ""; return n.mobileStr && n.mobileStr.length > 0 && (t = n.mobileStr.join("<br/>")), t }, attributes: { "class": "cell-left ", style: "padding: 0" } }, { field: "telephones[0].mobile", title: "电话", width: "200px", isHidden: !0, index: 4, code: "telephoneStr", template: function(n) { var t = ""; return n.telephoneStr && n.telephoneStr.length > 0 && (t = n.telephoneStr.join("<br/>")), t }, attributes: { "class": "cell-left", style: "padding: 0" } }] };
                    h = { field: "patient.privateId", title: "病历号", width: "80px", isHidden: !1, index: 10, code: "privateId", attributes: { style: "padding: 0" } };
                    n.gridOption.columns.push(h);
                    k = function(n) { var t = u("toFirstVisit")(n.isFirstVisit); return "" + ('<div style="display:inline;" title="' + t + '">' + t + "<\/div>") };
                    l.isAllowed("patientFollowup.create") && (h = { title: "全选", headerTemplate: "<input name='selectAll' id='selectAll' type='checkbox' />", width: "50px", index: n.showColumns && n.showColumns.indexOf("$") < 0 ? 1 : 15, sortable: !1, code: "selectAll", headerAttributes: { style: "text-align:center;" }, template: '<input type="checkbox" id="#: id #" patientId="#: patient.id #" doctorId="#: doctorId #" startTime="#: startTime #" consultantId="#: consultantId #"/>' }, n.gridOption.columns.splice(1, 0, h));
                    n.gridOption.columns.push({ field: "patient.otherPrivateId", title: "其他病历号", width: "100px", isHidden: !0, index: 11, code: "otherPrivateId", attributes: { style: "padding: 0" }, afterCode: "privateId" }, { field: "apptTimeStr", title: "预约/挂号", width: "90px", isHidden: !1, index: 20, code: "apptTimeStr", attributes: { style: "padding: 0" } }, { field: "patient.brithStr", title: "出生日期", width: "100px", isHidden: !0, index: 55, code: "brithStr", attributes: { style: "padding: 0" } }, { field: "patient.ageStr", title: "年龄", width: "50px", isHidden: !0, index: 58, code: "ageStr", attributes: { style: "padding: 0" } }, { field: "doctorName", title: "预约医生", width: "85px", isHidden: !1, index: 30, code: "doctorName", attributes: { style: "padding: 0" } }, { field: "consultantName", title: "咨询师", width: "85px", isHidden: !0, index: 40, code: "consultantName", attributes: { style: "padding: 0" } }, { field: "assistantName", title: "助理", width: "85px", isHidden: !0, index: 50, code: "assistantName", attributes: { style: "padding: 0" } }, { field: "transactionNames", title: "预约项目", width: "100px", isHidden: !1, index: 60, code: "transactionNames", attributes: { "class": "cell-left cell-truncate", style: "padding: 0" } }, { field: "checkInType", title: "就诊类型", width: "85px", isHidden: !0, index: 75, code: "checkInType", attributes: { style: "padding: 0" } }, { field: "stateStr", title: "就诊状态", width: "85px", sortable: !1, isHidden: !1, index: 80, code: "stateStr", attributes: { "class": "appointment-status-td cell-nowrap", style: "padding: 0" } }, { field: "notes", title: "备注", isHidden: !1, width: "143px", index: 90, code: "notes", attributes: { "class": "cell-left cell-truncate", style: "padding: 0" } }, { field: "patientSourceType", title: "患者来源", width: "120px", isHidden: !0, index: 100, code: "patientSourceType", attributes: { style: "padding: 0" } }, { field: "patientCreatedUser", title: "患者创建人", width: "100px", isHidden: !0, index: 110, code: "patientCreatedUser", attributes: { style: "padding: 0" } }, { field: "apptCreatedUser", title: "预约创建人", width: "100px", isHidden: !0, index: 120, code: "apptCreatedUser", attributes: { style: "padding: 0" } }, { field: "appointmentTimeStr", title: "预约时间", width: "130px", isHidden: !0, index: 130, code: "appointmentTimeStr", attributes: { style: "padding: 0" } }, { field: "checkInTimeStr", title: "挂号时间", width: "100px", index: 140, isHidden: !0, code: "checkInTimeStr", attributes: { style: "padding: 0" } }, { field: "operatoryId", title: "诊室", width: "100px", isHidden: !0, index: 150, code: "operatoryId", attributes: { style: "padding: 0" } }, { field: "department", title: "科室", width: "100px", isHidden: !0, index: 160, code: "department", attributes: { style: "padding: 0" } }, { field: "apptSourceType", title: "预约来源", width: "100px", isHidden: !0, index: 170, code: "apptSourceType", attributes: { style: "padding: 0" } }, { field: "appointmentType", title: "预约类型", width: "100px", isHidden: !0, index: 180, code: "appointmentType", attributes: { style: "padding: 0" } }, { title: "就诊流程", width: t ? "205px" : "115px", index: 190, code: "apptWorkflow", template: function(n) { if (n.workflowCommands || (n.workflowCommands = a), t) return '<ares-command-group commands="::dataItem.workflowCommands" tag="::dataItem"><\/ares-command-group>'; var i = f.dataItems(),
                                r = i.indexOf(n) + 1,
                                u = r >= 5; return u ? '<ares-command-group commands="::dataItem.workflowCommands" tag="::dataItem" mode="menu" menu-direction="up"><\/ares-command-group>' : '<ares-command-group commands="::dataItem.workflowCommands" tag="::dataItem" mode="menu"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:" + (t ? "145px" : "115px;padding: 0") } }, { title: "预约操作", index: 200, code: "apptOperation", isHidden: !1, width: "105px", template: function(n) { if (!n.actionCommands) { if (n.actionCommands = angular.copy(v), vt(n)) { n.actionCommands[0].text = "修改挂号"; var t = s.isAtCurrentOffice(n) && (n.isPending || s.compareApptState(n, "<isCheckedOut"));
                                    t && (n.actionCommands[0].canExec = !1) } Ares.isHistory(n.startTime) && (n.beforeAppt = !0) } return '<ares-command-group commands="::dataItem.actionCommands" tag="::dataItem"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:110px;padding: 0" } }, { width: "40px", index: 210, code: "sendMsg", isHidden: !1, template: function(n) { return n.messageCommands || (n.messageCommands = y), '<ares-command-group commands="::dataItem.messageCommands" tag="::dataItem"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:40px;padding: 0" } }, { width: "40px", index: 220, code: "print", isHidden: !1, template: function(n) { return n.printCommands || (n.printCommands = w), '<ares-command-group commands="::dataItem.printCommands" tag="::dataItem"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:40px;padding: 0" } }, { width: "40px", index: 220, code: "charge", isHidden: !1, template: function(n) { return n.chargeCommands || (n.chargeCommands = b), n.isStrongStrict || (n.isStrongStrict = r), n.isStrict || (n.isStrict = t), '<ares-command-group commands="::dataItem.chargeCommands" tag="::dataItem"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:40px;padding: 0" } });
                    e = n.showColumns.split(",");
                    e = _.filter(e, function(n) { return n.indexOf("undefined") == -1 });
                    c = _.filter(n.gridOption.columns, function(n) { if (n.afterCode) { var t = _.any(e, function(t) { return t == n.code }); return !t } return !1 });
                    o = [];
                    c && c.length ? _.each(e, function(n) { o.push(n); var t = _.find(c, { afterCode: n });
                        t && (t.isHidden ? o.push("-" + t.code) : o.push(t.code)) }) : o = e;
                    p.formatColumns(n.gridOption.columns, o, tt);
                    n.gridOption.columns = _.sortBy(n.gridOption.columns, "index");
                    angular.forEach(n.gridOption.columns, function(n) { tt.push({ code: n.code, width: n.width }) }) },
                at = function(t) { r.find("#apptList td input[type='checkbox']").each(function() { var i = $(this),
                            r = parseInt(i.attr("id")),
                            u = parseInt(i.attr("patientId")),
                            f = i.attr("doctorId"),
                            e = i.attr("startTime"),
                            o = i.attr("consultantId");
                        this.checked = t;
                        this.checked ? _.find(n.selectedAppts, { id: r }) === undefined && n.selectedAppts.push({ id: r, patientId: u, doctorId: f, startTime: e, consultantId: o }) : n.selectedAppts = _.reject(n.selectedAppts, { id: r }) }) },
                ni = function() { r.find("#apptList td input[type='checkbox']").each(function() { var t = this;
                        $(t).on("click", function() { var t = $(this),
                                u = parseInt(t.attr("id")),
                                f = parseInt(t.attr("patientId")),
                                e = t.attr("doctorId"),
                                o = t.attr("startTime"),
                                s = t.attr("consultantId"),
                                i;
                            this.checked ? (_.find(n.selectedAppts, { id: u }) === undefined && n.selectedAppts.push({ id: u, patientId: f, doctorId: e, startTime: o, consultantId: s }), r.find("#apptList td input[type='checkbox']:enabled").length === r.find("#apptList td input[type='checkbox']:checked").length && (i = r.find("#apptList th input[type='checkbox']")[0], i.checked = !0)) : (n.selectedAppts = _.reject(n.selectedAppts, { id: u }), i = r.find("#apptList th input[type='checkbox']")[0], i.checked = !1) }) });
                    r.find("#apptList th input[type='checkbox']").each(function() { var n = this,
                            t; if ($(n).attr("title", "全选"), t = $(n).attr("name"), t === "selectAll") { $(n)[0].checked = !1;
                            $(n).on("click", function() { this.checked ? at(!0) : at(!1) }) } }) },
                ti = function(t) { var i = r.find("#apptList th input[type='checkbox']"),
                        u, f, e; if (i && i.length > 0 && i.parent().css("display") == "none") { a.info("创建随访计划", "请选择要创建随访的预约"); return } if (t && t.length == 0 || !t) { a.info("创建随访计划", "请选择要创建随访的预约"); return } u = [];
                    angular.forEach(t, function(n) { u.push({ apptId: n.id, patientId: n.patientId, apptStartTime: n.startTime, apptDoctorId: n.doctorId, apptConsultantId: n.consultantId }) });
                    f = { creatorId: v.userId, followupRule: { ruleType: o.FollowupRuleType.ManualRule, creationMode: o.FollowupCreationMode.AllAtOnce, timeMode: o.FollowupTimeMode.Absolute } };
                    e = w.openBatchCreateFollowupDialog(f, u);
                    e.then(function() { n.updateFollowupCount() }) },
                vt = function(n) { return n.isCheckedIn || n.isSeated || n.isCompleted ? !0 : !1 },
                ot = function(n, i) { ht && t.cancel(ht);
                    ht = t(function() { if (i) { var t = _.find(tt, { code: n.column.code });
                            t && (t.width = n.newWidth + "px", lt.saveObject(tt)) } else p.updateColumnsOption(p.keys.todayCheckedInPatientGridOption, n.sender.columns, dt) }, 1500) },
                gi = function() { var o = r.find("#apptList"),
                        f = o.find(".k-grid-header"),
                        c = o.find(".k-grid-content"),
                        n = f.find("col"),
                        t = c.find("col"),
                        s = $(f).width(),
                        e = 85; if (n.each(function(n, t) { n != 4 && (e += $(t).width()) }), $(n[0]).css("width", "102px"), $(t[0]).css("width", "102px"), e >= s && n.length > 4) $(n[4]).css("width", "85px"), $(t[4]).css("width", "85px");
                    else { var i = s - e + "px",
                            l = f.find("thead").find("tr"),
                            h = null,
                            u = null;
                        l.find("th").each(function(n, t) { var i = $(t).text(),
                                r = $(t).css("display");
                            i == "预约项目" && r != "none" && (h = n);
                            i == "备注" && r != "none" && (u = n) });
                        h == null && (u ? ($(n[u]).css("width", i), $(t[u]).css("width", i)) : ($(n[0]).css("width", i), $(t[0]).css("width", i))) } },
                ii = function() { var t = r.find("#apptList");
                    f = t.data("kendoGrid");
                    f && (f.dataSource.data(n.filteredAppts), d = ut.loadObject(), yt(f, d));
                    r.find("#apptList th").bind("click", function() { yt(f) }) },
                yt = function(n, t) { if (d = n.dataSource.sort(), t && (d = t), d && d.length > 0) { var i = _.find(d, { field: "appointmentTimeStr" });
                        i || (ut.saveObject(d), d.push({ field: "appointmentTimeStr", dir: "asc" }), n.dataSource.sort(d)) } else t || ut.saveObject([]) },
                ri = function() { ii() },
                ui = function() { var n = e.params.apptId || bt;
                    n && t(function() { ct(n) }, 500) },
                fi = function(n, t) { n.action === "complete" && (n.isDisabled = t.isCompleted) },
                ei = function(t) { var i, r, u;
                    n.updateCount();
                    f ? (f.dataSource.data(n.filteredAppts), i = f.pager.pageSize() || 5, r = f.pager.page() || 1, n.filteredAppts.length < i && r > 1 ? f.dataSource.page(1) : (n.isResetPage && (f.dataSource.page(1), n.isResetPage = !1), u = i * r, n.filteredAppts.length < u && f.dataSource.page(1))) : ri();
                    t ? ct(t) : it && ct(it) },
                ct = function(n) { var i = $(r).find("#apptList"),
                        u = i.data("kendoGrid"),
                        e = u.dataSource,
                        f = e.get(n),
                        t;
                    f && (t = i.find("tbody>tr[data-uid=" + f.uid + "]"), t ? (u.select(t), it = n) : it = null) },
                oi = function() { h.subscribe(n, h.events.AppointmentCreated, st);
                    h.subscribe(n, h.events.AppointmentUpdated, st) },
                si = function() { h.unsubscribe(n, h.events.AppointmentCreated, st);
                    h.unsubscribe(n, h.events.AppointmentUpdated, st) },
                st = function(i, r) { n.refreshAppt(r);
                    r._apptAction == "Complete" && t(function() { hi(r) }, 300) },
                hi = function(n) { var t = r.find("#apptState" + n.id);
                    t.effect("pulsate", { times: 2 }) },
                ci = function() { ft = e.current;
                    ft.onActivated = n.refresh },
                pt = function(i) { ei(i);
                    n.refreshApptStates && t(n.refreshApptStates, 200) },
                li = function() { var t = moment(n.date).toDate(),
                        i = moment(n.date).add(1, "d").toDate(); return new Ares.DateRange(t, i) },
                ai = function() { n.loadColumnsOption().then(function() { y.getOfficeOption(y.optionKeys.StrictApptWorkflow).then(function(n) { y.getOfficeOption(y.optionKeys.EnableConsultantDiagnose).then(function(t) { y.getOfficeOption(y.optionKeys.IsStrongStrictApptWorkflowEnabled).then(function(i) { vi();
                                    gt(n, t, i) }) }) }) });
                    oi();
                    ci();
                    r.find(".isHideData").hide();
                    r.find("#daysBeforeTodayInput").change(function() { this.value == "自定义" ? r.find(".isHideData").show() : r.find(".isHideData").hide() }) },
                vi = function() { var n; if (rt && (n = rt.loadObject(), et = n.pageSize), !et) { var t = $(window).height(),
                            i = t - 240,
                            r = i - 81;
                        et = Math.max(5, parseInt(r / 40)) } },
                yi = function() { var i = r.find("#daySelectBtn");
                    i.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectBtn").datepicker("hide");
                        n.isInitialize ? n.isInitialize = !1 : t(function() { n.date = i.date;
                            n.refresh() }, 100) });
                    i.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                pi = function() { r.find("#daySelectBtn").datepicker("update", moment(n.date).format("YYYY-MM-DD")) },
                wi = function() { t(function() { var n = r.find("#apptList").data("kendoGrid"),
                            t;
                        n && (t = n.pager, t && t.element.bind("change", function() { var t = n.dataSource.pageSize();
                            rt && rt.saveObject({ pageSize: t }) })) }, 1e3) },
                wt = function(n) { var t = [],
                        i, r;
                    n && n.department && t.push("department=" + n.department);
                    n && n.operatory && t.push("operatory=" + n.operatory);
                    n && n.speechName && t.push("speechName=" + n.speechName);
                    i = t.join("&");
                    r = "/speechcallpatient?" + i;
                    window.open(r, "_blank") },
                bi = function() { b.getSpeechCallSearchConfigs().success(function(n) { if (n && n.length != 0) { var t = i.open({ animation: !0, backdrop: "static", template: "<speech-call-select-view><\/speech-call-select-view>", controller: "SpeechCallSelectCtrl", size: "md", resolve: { host: function() { return { configs: n } } } });
                            t.result.then(function(n) { n && wt(n) }) } else wt() }) },
                ki = function() { var t = g.open("<office-resource-view><\/office-resource-view>", "OfficeResourceCtrl", { host: function() { return {} } }, n, "office-resource-slide-modal") },
                di = function() { nt.goToState("pttCenter") };
            (function() { n.selectedAppts = [];
                n.today = new Date;
                n.refreshDate = pi;
                n.formatCommand = fi;
                n.getDateRange = li;
                n.refreshAppts = pt;
                n.refreshedTime = Ares.timestamp();
                n.getStatus = vt;
                n.showOfficeResource = ki;
                n.createBatchFollowup = ti;
                n.openSpeechCallSelect = bi;
                n.openPreTestTriage = di;
                yi();
                ai();
                wi();
                n.$watch("filteredAppts", function() { n.filteredAppts && (pt(), ui()) });
                n.$on("$destroy", function() { si();
                    ft && (ft.onActivated = null) }) })() } } }]);
dashboardModule.directive("todayFirstVisitPatientListView", ["$log", "$timeout", "$filter", "$window", "appNav", "officeSvc", "apptUtil", "gridOptionUtil", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", replace: !0, controller: "TodayFirstVisitPatientListCtrl", templateUrl: "/app/dashboard/views/today-first-visit-patient-list-view.html", scope: { officeId: "=" }, link: function(n, i) { var nt = Ares.kendoGridUtil(r, n),
                s = !1,
                h = 6;
            r.AdminOfficePatientCtrl_goToPatient = function(n) { n && u.goToPatient(n) };
            i.find(".isHideData").hide(); var c = function() { var t, r, u, f;
                    n.searchText || (n.filteredAppts = n.adminOfficeAppointments);
                    n.filteredAppts && (t = [{ text: "回访", exec: n.addRevisit }, { text: "修改", exec: n.updateAppt, canExec: e.canEditAdmin }, { text: "取消", exec: n.cancelAppt, canExec: e.canCancelAdmin }, ], s = !0, r = $(window).height() - 225, n.gridOption = { pageable: o.getPageable(h), resizable: !0, model: { id: "id" }, columns: [], height: r }, n.gridOption.columns.push({ field: "patient.nameCode", title: "姓名", width: "102px", sortable: !1, index: 1, code: "patientName", attributes: { "class": "patient-td", style: "padding: 0" }, template: function() { return '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="noIcon" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "recordCreatedTimeStr", title: "创建时间", width: "120px" }, { field: "isCompletedStr", title: "成交", width: "60px", template: function(n) { return n && n.isCompleted ? "<font>{{dataItem.isCompletedStr}}<\/font>" : '<font style="color:red">{{dataItem.isCompletedStr}}<\/font>' } }, { field: "isChargeStr", title: "消费", width: "60px", template: function(n) { return n && n.chargeOrderId > 0 ? "<font>{{dataItem.isChargeStr}}<\/font>" : '<font style="color:red">{{dataItem.isChargeStr}}<\/font>' } }, { field: "abbreviation", title: "预约门店", width: "120px" }, { field: "appointmentTimeStr", title: "预约时间", width: "73px" }, { field: "checkInTimeStr", title: "到店时间", width: "73px", template: function(n) { return n && n.checkInTime ? "<font>{{dataItem.checkInTimeStr}}<\/font>" : '<font style="color:red">未到店<\/font>' } }, { field: "doctorName", title: "医生", width: "120px" }, { field: "consultantName", title: "咨询师", width: "120px" }, { title: "操作", index: 200, code: "apptOperation1", isHidden: !1, width: "130px", template: function(n) { return n.actionCommands || (n.actionCommands = t), '<ares-command-group commands="::dataItem.actionCommands" tag="::dataItem"><\/ares-command-group>' }, attributes: { "class": "cell-crowded", style: "min-width:110px;padding: 0" } }), u = i.find("#adminOfficeAppointmentList"), f = u.data("kendoGrid"), f && patientList.dataSource.data(n.filteredAppts)) },
                l = function(t, i, r) { n.$apply(function() { var n = findFollowupPatient(r); switch (i) {
                            case "goToPatient":
                                u.goToPatient(n.patientId) } }) },
                a = function() { p();
                    y(); var r = i.find("#daySelectAdminOfficeBtn");
                    r.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectAdminOfficeBtn").datepicker("hide");
                        n.isInitialized ? n.isInitialize = !1 : t(function() { n.date = i.date;
                            n.loadAppointments() }, 100) });
                    r.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                v = function() { $("#daySelectAdminOfficeBtn").datepicker("update", moment(n.date).format("YYYY-MM-DD")) },
                y = function() { f.list().success(function(t) { var r = t,
                            u;
                        r.splice(0, 0, { id: -1, abbreviation: "全部" });
                        u = i.find("#officeInput");
                        u.kendoDropDownList({ dataSource: r, placeholder: "", dataTextField: "abbreviation", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                                n.currentOfficeId = i.id;
                                n.loadAppointments() } }) }) },
                p = function() { var t = i.find("#appointmentTypeInput");
                    t.kendoDropDownList({ dataSource: [{ id: 0, name: "我创建的初诊" }, { id: 1, name: "我创建的预约" }, { id: 2, name: "所有的初诊" }, { id: 3, name: "所有的预约" }], placeholder: "", dataTextField: "name", dataValueField: "id", select: function(t) { var i = this.dataItem(t.item.index());
                            n.appointmentType = i.id;
                            n.loadAppointments() } }) },
                w = function() { t(function() { var n = i.find("#adminOfficeAppointmentList").data("kendoGrid"),
                            t;
                        n && (t = n.pager, t && t.element.bind("change", function() { var t = n.dataSource.pageSize();
                            h = t })) }, 1e3) },
                b = function() { var f = i.find("#adminOfficeAppointmentList"),
                        t = f.data("kendoGrid"),
                        u, r;
                    t.dataSource.data(n.filteredAppts);
                    u = t.pager.pageSize() || 5;
                    r = t.pager.page() || 1;
                    n.filteredAppts.length <= u * (r - 1) && r > 1 && t.dataSource.page(1) },
                k = function(t) { n.patientId = t.patientId;
                    n.isShowRevisitEditDialog = !0 },
                d = function() { n.isShowRevisitEditDialog = !1 },
                g = function(t) { n.selectedCheckInState = t;
                    n.loadAppointments() };
            (function() { n.searchText = null;
                n.selectedCheckInState = -1;
                n.currentOfficeId = -1;
                n.appointmentType = 0;
                n.onCommandClick = l;
                n.refreshDate = v;
                n.switchState = g;
                n.addRevisit = k;
                n.hideRevisitEditDialog = d;
                a();
                w();
                n.$watch("filteredAppts", function() { s ? b() : (n.loadAppointments(), c()) }) })() } } }]);
dashboardModule.directive("todayWorkSettingView", ["$log", "$timeout", function(n, t) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/today-work-setting-view.html", link: function(n, i) { var r, u = function() { var t = this;
                    $(i).find("#dashboardList input[type='checkbox']").each(function(t) { var i = this;
                        $(i).attr("index", t);
                        $(i).attr("checked", n.dashboard[t].configValue);
                        $(i).attr("checkValue", n.dashboard[t].configValue);
                        $(i).bind("click", function() { $(this).attr("checkValue", $(this).attr("checkValue") == "true" ? "false" : "true"); var t = $(this).attr("index");
                            n.dashboard[t].configValue = $(this).attr("checkValue") == "true" ? !0 : !1;
                            n.hasChanged = !0 }) }) },
                f = function() { if (n.dashboard) { var f = $(i).find("#dashboardList");
                        r = f.kendoGrid({ dataSource: n.dashboard, columns: [{ field: "是否显示", width: "50px", template: "<input  type='checkbox' />" }, { field: "coments", title: "名称", width: "140px" }], scrollable: !1, sortable: !1, selectable: "single", dataBound: u, change: function() { var i = this.dataItem(this.select());
                                i.id && t(function() { n.selectedItem = i ? i : null }) } }).data("kendoGrid") } },
                e = function() { r ? (r.dataSource.data(n.dashboard), o()) : f() },
                o = function() { if (n.selectedItem) { var i = r.dataSource,
                            u = i.get(n.selectedItem.id),
                            t = r.element.find("tbody>tr[data-uid=" + u.uid + "]");
                        t && r.select(t) } };
            (function() { n.$watch("dashboard", function() { n.dashboard && e() }) })();
            t(function() { Ares.centerModal(i.closest(".modal-dialog")) }, 300) } } }]);
dashboardModule.directive("unchargedPatientListView", ["$log", "$timeout", "$filter", "$window", "appNav", "dashboardSvc", "patientSvc", "enums", "$state", function(n, t, i, r, u, f, e, o, s) { "use strict"; return { restrict: "E", replace: !0, controller: "UnchargedPatientCtrl", templateUrl: "/app/dashboard/views/uncharged-patient-list-view.html", scope: { officeId: "=" }, link: function(n, i) { var f = null,
                e, o, h;
            i.find(".isHideData").hide();
            i.find("#unchargedTodayInput").change(function() { i.find("#unchargedTodayInput").val() == "自定义" ? i.find(".isHideData").show() : i.find(".isHideData").hide() });
            e = !1;
            r.UnchargedPatientCtrl_goToPatient = function(n) { n && u.goToPatient(n) };
            n.goToChargeHistory = function(n) { n.preventDefault(); var t = this.dataItem($(n.currentTarget).closest("tr"));
                t && t.patientId && u.goToCharge(t.patientId) };
            n.goToChargeConfirm = function(t) { t.preventDefault(); var i = this.dataItem($(t.currentTarget).closest("tr"));
                i && i.patientId && (n.allowNewCharge ? n.showNewChargeConfirm(i, n.unchargeAppts) : n.showChargeConfirm(i)) };
            o = function() { if (n.unchargeAppts) { e = !0; var t = i.find("#patientList");
                    f = t.kendoGrid({ dataSource: { data: n.unchargeAppts }, scrollable: !1, sortable: !0, selectable: "single", model: { id: "id" }, columns: [{ field: "patientName", title: "姓名", width: "150px", template: '<a href="javascript:void(0)" onclick="UnchargedPatientCtrl_goToPatient(#: patientId #)" >#: patientName #<\/a>' }, { field: "privateId", title: "病历号", width: "80px" }, { field: "startTime", title: "就诊时间", width: "150px" }, { field: "sexStr", title: "性别", width: "60px" }, { field: "mobile", title: "手机号", width: "60px" }, { field: "doctorName", title: "医生", width: "60px" }, { field: "finalPrice", title: "应收款（优惠后）", width: "60px", format: "{0:n}" }, { command: [{ name: "收费历史", click: n.goToChargeHistory }, { name: "收费", click: n.goToChargeConfirm }], title: "", width: "200px" }] }).data("kendoGrid") } };
            h = function() { var t = new kendo.data.DataSource({ data: n.unchargeAppts });
                    f.setDataSource(t);
                    f.refresh() },
                function() { n.$emit("to-parent-current-state", s.current.name);
                    n.$watch("unchargeAppts", function() { n.updateCount();
                        n.unchargeAppts && (e ? t(function() { h() }) : o()) });
                    n.$on("$destroy", function() { delete r.UnchargedPatientCtrl_goToPatient }) }() } } }]);
dashboardModule.directive("customerServiceDashboardConsultQuantityView", ["$log", "$window", "$q", "patientUtil", "enums", "dataDicSvc", "loginContext", "$modal", "moduleOptionProvider", "gridOptionUtil", "dashboardSvc", "aresNotification", "$filter", "reportUtil", "practiceSvc", "multiOfficeDataDic", "baiduAreaSvc", "patientSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) { return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-consult-quantity-view.html", controller: "CustomerServiceDashboardConsultQuantityCtrl", link: function(n, r) { var o, a = function() { var u = t.innerHeight - 180,
                        i = r.find("#consultQuantityList"),
                        f = [];
                    n.intentionsColumns && angular.forEach(n.intentionsColumns, function(n) { f.push(n) });
                    i.html("");
                    o = i.kendoGrid({ dataSource: { data: n.consultQuantityList, aggregate: n.aggregate, group: { field: "visitDateStr", aggregates: n.aggregate } }, height: u, excel: { fileName: "咨询量.xlsx" }, sortable: !0, resizable: !0, reorderable: !0, selectable: "single", model: { id: "id" }, columns: n.intentionsColumns }).data("kendoGrid") },
                v = function() { var t = new Date;
                    n.date.startDate = moment(t).startOf("month").format("YYYY-MM-DD");
                    n.date.endDate = moment(t).endOf("month").format("YYYY-MM-DD") },
                y = function() { var t = {},
                        i = new Date; return t.startDate = moment(n.date.startDate).format("YYYY-MM-DD"), t.endDate = moment(n.date.endDate).format("YYYY-MM-DD"), t },
                p = function() { var t = y(),
                        i = { startDate: t.startDate, endDate: moment(t.endDate).add(1, "day").format("YYYY-MM-DD"), isByIntentionDesc: n.isByIntentionDesc, sourceLevel1: n.sourceLevel1, sourceLevel2: n.sourceLevel2, sourceLevel3: n.sourceLevel3, level: n.level, isGroup: e.isGroup }; return n.criteria = i, i },
                k = function() { v();
                    g();
                    nt() },
                h = function() { var t = p(); if (moment(t.startDate).add(1, "M") < moment(t.endDate)) { l.error("查询范围请缩小至一月！"); return } if (!n.isByIntentionDesc && !n.current.city) { l.error("请精准至市查询！"); return } n.search(t).then(function() { a() }) },
                d = function(t) { n.isByIntentionDesc = t },
                f = function(t, r) { var u = i.defer(); return n.criteria = { areaCode: t, areaType: r }, w.getSubBaiduAreas(n.criteria).success(function(n) { u.resolve(n) }).error(function(n) { u.reject(n) }), u.promise },
                u = function(n, t, i) { var u = r.find(n),
                        f = u.kendoDropDownList({ dataSource: t, optionLabel: "请选择", dataTextField: "areaName", dataValueField: "areaName", filter: "contains", value: i, select: function(n) { i = this.dataItem(n.item)[this.options.dataValueField] || null } }).data("kendoDropDownList") },
                s = function(n, t) { var r = 1,
                        i = _.filter(n, { areaName: t }); return i && i.length > 0 && (r = i[0].areaCode), r },
                g = function() { n.current && f(1, 1).then(function(t) { var i, r, e; if (n.currentProvinces = t, u("#province", n.currentProvinces, n.current.province), c("#province", "#city", n.currentProvinces), i = n.current.province, i == "北京市" || i == "天津市" || i == "上海市" || i == "重庆市" || i == "澳门特别行政区" || i == "香港特别行政区") { n.currentCitys = [{ areaName: i }];
                            n.currentDistricts = [];
                            u("#city", n.currentCitys, n.current.city);
                            r = s(n.currentProvinces, i);
                            (n.current.district || n.current.city && !n.current.district) && $timeout(f(r, 3).then(function(t) { n.currentDistricts = t;
                                u("#district", n.currentDistricts, n.current.district) }), 200); return } n.current.province && (e = s(n.currentProvinces, n.current.province), $timeout(f(e, 2).then(function(t) { n.currentCitys = t;
                            u("#city", n.currentCitys, n.current.city); var i = s(n.currentCitys, n.current.city);
                            (n.current.district || n.current.city && !n.current.district) && $timeout(f(i, 3).then(function(t) { n.currentDistricts = t }), 200) }), 200)) }) },
                c = function(t, i, e) { var o = r.find(t),
                        s = r.find(i);
                    o.change(function() { var r, h, c; if (s) { if (r = o.val(), h = i == "#city" ? 2 : 3, !r) { h == 2 && (n.currentCitys = [], n.current.city = null);
                                $timeout(function() { n.currentDistricts = [];
                                    n.current.district = null }, 200); return } if (h == 2 && (n.currentDistricts = []), c = _.filter(e, { areaName: r }), r == "北京市" || r == "天津市" || r == "上海市" || r == "重庆市" || r == "澳门特别行政区" || r == "香港特别行政区") { if (t == "#province") { n.currentCitys = [{ areaName: r }];
                                    n.currentDistricts = [];
                                    u("#city", n.currentCitys, undefined); return } c = _.filter(n.currentProvinces, { areaName: r }) } if (c && c.length == 0) return;
                            f(c[0].areaCode, h).then(function(t) { h == 2 ? n.currentCitys = t : n.currentDistricts = t }) } }) },
                nt = function() { b.getPatientSourceTypesByOffice(e.officeId).success(function(t) { n.sourceTypeData = t;
                        tt() }) },
                tt = function() { var i = [{ itemName: "全部一级来源" }],
                        t;
                    Array.prototype.push.apply(i, n.sourceTypeData.filter(function(n) { return n.level === 1 }).map(function(n) { return { itemName: n.sourceName } }));
                    t = r.find("#sourceTypeOne").kendoDropDownList({ autoBind: !0, dataTextField: "itemName", dataValueField: "itemName", valuePrimitive: !0, dataSource: i, filter: "contains", select: function(t) { var i = this.dataItem(t.item.index());
                            n.sourceLevel1 = i.itemName == "全部一级来源" ? null : i.itemName;
                            it(i.itemName) } }).data("kendoDropDownList");
                    t && t.select(0);
                    n.sourceTypeTwoDropdown = r.find("#sourceTypeTwo").kendoDropDownList({ autoBind: !0, dataTextField: "itemName", dataValueField: "itemName", valuePrimitive: !0, dataSource: [{ itemName: "全部二级来源" }], filter: "contains", select: function(t) { var i = this.dataItem(t.item.index());
                            n.sourceLevel2 = i.itemName == "全部二级来源" ? null : i.itemName;
                            rt(i.itemName) } }).data("kendoDropDownList");
                    n.sourceTypeThreeDropdown = r.find("#sourceTypeThree").kendoDropDownList({ autoBind: !0, dataTextField: "refereeName", dataValueField: "refereeName", valuePrimitive: !0, filter: "contains", dataSource: [{ refereeName: "全部三级来源" }], select: function(t) { var i = this.dataItem(t.item.index());
                            n.sourceLevel3 = i.refereeName == "全部三级来源" ? null : i.refereeName } }).data("kendoDropDownList") },
                it = function(t) { if (n.sourceTypeTwoDropdown) { t !== "全部一级来源" && t || (n.sourceTypeTwoData = [{ itemName: "全部二级来源" }], n.sourceTypeTwoDropdown.dataSource.data(n.sourceTypeTwoData), n.sourceTypeTwoDropdown.value("全部二级来源"), n.sourceLevel2 = null, n.sourceLevel3 = null, n.sourceTypeThreeData = [{ refereeName: "全部三级来源" }], n.sourceTypeThreeDropdown.dataSource.data(n.sourceTypeThreeData), n.sourceTypeThreeDropdown.value("全部三级来源")); var i = n.sourceTypeData.find(function(n) { return n.sourceName === t && n.level === 1 });
                        i && (n.sourceTypeTwoData = n.sourceTypeData.filter(function(n) { return i.id === n.parentId && n.level === 2 }).map(function(n) { return { itemName: n.sourceName } }), n.sourceTypeTwoData.unshift({ itemName: "全部二级来源" }), n.sourceTypeTwoDropdown.dataSource.data(n.sourceTypeTwoData), n.sourceTypeTwoDropdown.value("全部二级来源"), n.sourceTypeThreeData = [{ refereeName: "全部三级来源" }], n.sourceTypeThreeDropdown.dataSource.data(n.sourceTypeThreeData), n.sourceTypeThreeDropdown.value("全部三级来源")) } },
                rt = function(t) { n.sourceTypeThreeDropdown && (n.sourceTypeOne != "" && n.sourceTypeTwo != "" ? b.searchReportRefereeNames(t).success(function(t) { n.sourceTypeThreeData = t; var i = _.filter(n.sourceTypeThreeData, function(n) { return n.refereeName == "全部" });
                        i.length == 0 && n.sourceTypeThreeData.unshift({ refereeName: "全部三级来源" });
                        n.sourceTypeThreeData[0].refereeName == "全部" && (n.sourceTypeThreeData[0].refereeName = "全部三级来源");
                        n.sourceTypeThreeDropdown.dataSource.data(n.sourceTypeThreeData);
                        n.sourceTypeThreeDropdown.value("全部三级来源") }) : (n.sourceTypeThreeData = [{ refereeName: "全部三级来源" }], n.sourceLevel3 = null, n.sourceTypeThreeDropdown.dataSource.data(n.sourceTypeThreeData), n.sourceTypeThreeDropdown.value("全部三级来源"))) },
                ut = function() { o && o.saveAsExcel() };
            (function() { n.date = {};
                n.current = {};
                n.currentProvinces = [];
                n.currentCitys = [];
                n.currentDistricts = [];
                n.level = 0;
                n.isByIntentionDesc = !0;
                n.radioSource = d;
                n.onSearch = h;
                n.exportExcel = ut;
                k();
                n.$on("level", function(t) { n.level = t.targetScope.level;
                    h() });
                n.$emit("needRefreshLevel", function() {});
                n.$watch("currentCitys", function() { u("#city", n.currentCitys, undefined);
                    c("#city", "#district", n.currentCitys) });
                n.$watch("currentDistricts", function() { u("#district", n.currentDistricts, undefined) }) })() } } }]);
dashboardModule.directive("customerServiceDashboardFrontView", ["$log", "$state", "$rootScope", "$window", "$timeout", "patientUtil", "enums", "appNav", "loginContext", "aresModalShelf", function(n, t, i, r, u, f, e, o, s, h) { return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-front-view.html", scope: { groupType: "&" }, controller: "CustomerServiceDashboardFrontCtrl", link: function(n, u) { var a = function() { var n = angular.element(r).height(),
                        t = n - 62,
                        i = u.find(".customer-service-left-nav");
                    i.height(t) },
                c = ["dashBoard.groupCustomerTodayCheck", "dashBoard.groupCustomerRevisitPlan", "dashBoard.groupCustomerReportHome", "dashBoard.groupPendingAppt"],
                l = function(t, r) { var u = c[t];
                    n.state = t;
                    n.level = r ? r : 0;
                    i.level = r;
                    o.switchState(u) },
                v = function() { var t = f.getPatientPermissionLevel();
                    n.isAllLevel = t == e.PatientPermissionLevel.All;
                    n.isDepartmentLevel = t == e.PatientPermissionLevel.Department;
                    n.isPersonalLevel = t == e.PatientPermissionLevel.Personal },
                y = function(t) { n.level = t;
                    n.$broadcast("level", t); switch (t) {
                        case 0:
                            n.levelTitle = "我的"; break;
                        case 1:
                            n.levelTitle = "部门"; break;
                        case 2:
                            n.levelTitle = "全部" } },
                p = function() { var t = h.open({ template: "<customer-registration-view><\/customer-registration-view>", controller: "CustomerRegistrationCtrl", title: "客户登记", subTitle: "创建人：" + s.userName, titleIconClass: "", resolve: { host: function() { return {} } }, needActive: !0 });
                    t.result.then(function(t) { t && n.$broadcast("customerRegistration", 1) }) },
                w = function() { n.groupType({ type: "old" }) },
                b = function() { var n = 0; return t.current.name && t.current.name != "dashBoard" && (n = _.findIndex(c, function(n) { return n == t.current.name }) || 0), t.params.status && (n = _.findIndex(c, function(n) { return n == t.current.name }) || 0), n < 0 && (n = 0), n };
            (function() { n.levelTitle = "我的";
                n.switchState = l;
                n.backOldGroup = w;
                n.changeDepartment = y;
                n.openCustomerRegistrationDialog = p;
                n.$on("needRefreshLevel", function() { n.$broadcast("level", n.level) });
                v();
                a();
                l(b()) })() } } }]);
dashboardModule.directive("customerServiceDashboardMyPerformanceView", ["$log", "$window", "patientUtil", "enums", "dataDicSvc", "loginContext", "$modal", "moduleOptionProvider", "gridOptionUtil", "dashboardSvc", "aresNotification", "$filter", "reportUtil", "practiceSvc", "multiOfficeDataDic", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-my-performance-view.html", controller: "CustomerServiceDashboardMyPerformanceCtrl", link: function(n, i) { var p = 10,
                b = { pageIndex: 1, pageSize: p },
                u, a, k = function(t) { return function() { var i = 0; return (n.pageData && (i = n.pageData.sumInfo[t]), t === "sumDealCount") ? "<span>成交人数：<\/span>" + l("toPointStr")(i) : kendo.toString(i, "c2") } },
                d = [{ field: "patientName", title: "姓名", locked: !0, width: "180px", footerTemplate: k("sumDealCount") }, { field: "privateId", title: "病历号", width: "110px" }, { field: "tagStr", title: "患者标签", width: "110px" }, { field: "membershipName", title: "会员等级", width: "110px" }, { field: "onlineConsultantName", title: "网电咨询师", width: "110px" }, { field: "createdUser", title: "患者创建人", width: "110px" }, { field: "createdTimeStr", title: "患者创建时间", width: "110px" }, { field: "consultantName", title: "现场咨询师", width: "110px" }, { field: "consultItem", title: "咨询项目", width: "110px" }, { field: "startTimeStr", title: "预约时间", width: "110px" }, { field: "apptOfficeName", title: "预约门店", width: "110px" }, { field: "appointmentTypeStr", title: "预约类型", width: "110px" }, { field: "appointmentItem", title: "预约项目", width: "110px" }, { field: "payOfficeName", title: "就诊门店", width: "110px" }, { field: "visitSeqNo", title: "第几次到店", width: "110px" }, { field: "doctorName", title: "就诊医生", width: "110px" }, { field: "payDateTimeStr", title: "就诊时间", width: "110px" }, { field: "isDealtOrder", title: "是否成交", width: "110px", template: function(n) { if (n) return n.isDealtOrder ? "<span>是<\/span>" : "<span>否<\/span>" } }, { field: "itemSuperType", title: "收费大类", width: "110px" }, { field: "itemType", title: "收费小类", width: "110px" }, { field: "itemName", title: "收费项目", width: "110px" }, { field: "actualPrice", title: "绩效收入", width: "110px" }, { field: "dealAmount", title: "成交金额", width: "110px", format: "{0:n}", footerTemplate: k("sumDealAmount") }, { field: "overdue", title: "欠费金额", width: "110px" }, ],
                w = [{ field: "providerName", locked: !0, title: "网电姓名", width: "110px" }, { field: "employeeNo", title: "员工号", width: "110px" }, { field: "newPatientCount", title: "新建患者数", width: "150px" }, { field: "consultCount", title: "咨询人次", width: "110px" }, { field: "newAppointmentCount", title: "新建预约人次", width: "150px" }, { field: "visitRatio", title: "预约到店率", width: "150px" }, { field: "firstVisitCount", title: "首次到店人数", width: "150px" }, { field: "secondVisitCount", title: "二次到店人数", width: "150px" }, { field: "revisitCompleteRatio", title: "回访完成率", width: "150px" }, { field: "uncompleteRevisitCount", title: "未完成回访", width: "150px" }, { field: "firstVisitAmount", title: "首次成交金额", width: "150px" }, { field: "secondVisitAmount", title: "二次成交金额", width: "150px" }, { field: "moreVisitAmount", title: "再消费金额", width: "150px" }, { field: "dealCount", title: "成交人数", width: "110px" }, { field: "dealAmount", title: "成交金额", width: "110px" }, { field: "visitDealRatio", title: "到店成功率", width: "240px" }, { field: "dealAmountPerPerson", title: "人均成交金额", width: "150px" }, ],
                tt = function(n) { angular.forEach(n, function(n) { n.visitRatio = n.visitRatio.toFixed(2) + "%";
                        n.visitDealRatio = n.visitDealRatio.toFixed(2) + "%";
                        n.revisitCompleteRatio = n.revisitCompleteRatio.toFixed(2) + "%" }) },
                r = function(r, u, f, e, o, c) { var y = t.innerHeight - u,
                        v = i.find(r),
                        a;
                    v.html("");
                    a = s.getDefaultGridOption({ transport: { read: function(t) { var i = ot(f);
                                i ? (i.pageSize = b.pageSize, i.pageSize = b.pageSize, t.data && (i.pageIndex = t.data.page, i.pageSize = t.data.pageSize), f === "person" ? h.getNewPersonalOnlineConsultantReport(i).then(function(i) { n.pageData = i.data; var r = i.data.items;
                                    _.isArray(r) && r.length > 0 && _.each(r, function(n) { n.tagStr && (n.tagStr = n.tagStr.substring(0, n.tagStr.length - 1), n.tagStr = n.tagStr.substring(1));
                                        n.startTime && (n.startTimeStr = moment(n.startTime).format("YYYY-MM-DD HH:mm:ss"));
                                        n.payDateTime && (n.payDateTimeStr = moment(n.payDateTime).format("YYYY-MM-DD HH:mm:ss"));
                                        n.createdTime && (n.createdTimeStr = moment(n.createdTime).format("YYYY-MM-DD HH:mm:ss"));
                                        n.appointmentTypeStr = l("toAppointmentTypeStr")(n.appointmentType) });
                                    t.success({ data: i.data.items, total: i.data.totalCount }) }) : h.getNewDeptOnlineConsultantReport(i).then(function(n) { tt(n.data.items);
                                    t.success({ data: n.data.items, total: n.data.totalCount }) })) : t.success({ data: [], total: 0 }) } }, excel: { allPages: !0, fileName: c }, pageSize: p, serverPaging: !0, schema: { data: "data", total: "total" } }, e, y);
                    a.pageable = s.getPageable(p);
                    a.columnMenuInit = function(n) { $(n.container).find("ul.k-menu >li:not(.k-columns-item)").remove();
                        $(n.container).find("ul.k-menu >li.k-columns-item >div> ul> li.k-first").hide() };
                    n[o] = v.kendoGrid(a).data("kendoGrid") },
                it = function() { var t = new Date;
                    n.date.startDate = moment(t).startOf("month").format("YYYY-MM-DD");
                    n.date.endDate = moment(t).endOf("month").format("YYYY-MM-DD") },
                rt = function(n) { u = n;
                    Ares.sensors.track("CustomerServiceDashboardMyPerformance", { OperationType: "时间范围" }) },
                ut = function(n) { a = n },
                ft = function() { var t = angular.copy(n.selectedIdsStr),
                        r = angular.copy(n.selectedNamesMulti),
                        u = e.open({ animation: !0, backdrop: "static", template: "<office-group-dialog-view><\/office-group-dialog-view>", controller: "OfficeGroupDialogCtrl", windowClass: "office-group-dialog", resolve: { host: function() { return { selectMode: f.isGroup ? "multi" : "single", selectScope: "office", selectedIds: t, selectedNames: r, isDescendantDataOpen: o.isDescendantDataOpen() } } } });
                    u.result.then(function(t) { t && (n.selectedNamesMulti = t.selectedNames, n.selectedIdsStr = t.selectedIds, n.hasChange = !0, i.find("#txtOfficeInput").val(n.selectedNamesMulti), g(), nt()) }) },
                et = function(n) { var t = {},
                        i = new Date; return t.startTime = moment(i).startOf("month").format("YYYY-MM-DD"), t.endTime = moment(i).endOf(i).add(1, "day").format("YYYY-MM-DD"), n === "person" ? u && (t.startTime = u.startDate, t.endTime = moment(u.endDate).add(1, "day").format("YYYY-MM-DD")) : a && (t.startTime = a.startDate, t.endTime = moment(a.endDate).add(1, "day").format("YYYY-MM-DD")), t },
                ot = function(t) { var u = et(t),
                        r = { OnlineConsultantIds: f.providerId, officeIds: null, startTime: u.startTime, endTime: u.endTime, isGroup: f.isGroup, isAllDepartment: n.isAllDepartment ? !0 : !1 }; if (t === "person") { if (r.officeIds = n.isGroup ? n.selectedIdsStr || f.officeId : f.officeId, !n.selectedIdsStr && n.isSearchTrigger && n.isGroup) return c.error("请选择门店"), !1;
                        r.isDealt = "";
                        r.visitType = "";
                        n.person.patienIsDeal && n.searchMode && (r.isDealt = n.person.patienIsDeal.value);
                        n.person.visitType && n.searchMode && (r.visitType = n.person.visitType.value);
                        n.searchMode && (r.minDealAmount = n.dealDealAmount.minDealAmount || null, r.maxDealAmount = n.dealDealAmount.maxDealAmount || null, r.privateTag = i.find("#tagStr").val(), r.consultItem = n.consultItem == "全部" ? null : n.consultItem, r.appointmentItem = n.apptItem == "全部" ? null : n.apptItem);
                        r.selectCode = i.find("#selectCode").val() } return n.criteria = r, r },
                st = function() { it() },
                ht = function() { if (n.level > 0) { n.isSearchTrigger = !1;
                        n.isAllDepartment = n.level != 1; var t = n.level === 1 ? "部门绩效" : "全部绩效";
                        n.departmentPerformanceData ? n.departmentPerformanceData.dataSource.read() : r("#departmentPerformance", 90, "depart", w, "departmentPerformanceData", t + ".xlsx") } else n.isSearchTrigger = !0, n.personPerformanceData ? n.personPerformanceData.dataSource.read() : r("#personalPerformance", 160, "person", d, "personPerformanceData", "个人绩效.xlsx") },
                ct = function(n) { Ares.sensors.trackDropDownEvent("CustomerServiceDashboardMyPerformance", n) };
            n.exportExcel = function(t) { var i;
                t === 1 && n.personPerformanceData ? (i = { criteria: n.criteria, columns: n.personPerformanceData.columns }, h.exportNewPersonalOnlineConsultantReport(i)) : n.departmentPerformanceData && (i = { criteria: n.criteria, columns: n.departmentPerformanceData.columns }, h.exportNewDeptOnlineConsultantReport(i)) }; var lt = function() { n.searchMode = !n.searchMode;
                    n.searchMode && (g(), nt()) },
                g = function() { var u = f.isGroup ? n.selectedIdsStr : f.officeId,
                        t, r;
                    u ? (r = f.isGroup ? n.selectedIdsStr ? n.selectedIdsStr : 0 : f.officeId, v.getGroupSystemSettingItemsByItemType("咨询项目", r).success(function(t) { t.unshift({ itemName: "全部" });
                        i.find("#consultItem").kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", filter: "contains", dataSource: t, select: function(t) { n.consultItem = this.dataItem(t.item)[this.options.dataValueField] || null } }) })) : (t = [{ itemName: "全部" }], i.find("#consultItem").kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", dataSource: t })) },
                nt = function() { var t = f.isGroup ? n.selectedIdsStr : f.officeId,
                        r;
                    n.isGroup && (!t || t.indexOf(",") > 0) ? (r = [{ itemName: "全部" }], i.find("#apptItem").kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", dataSource: r })) : y.loadDic(t, "transactionCodeDic").then(function(t) { t.unshift({ name: "全部" });
                        i.find("#apptItem").kendoDropDownList({ dataTextField: "name", dataValueField: "name", filter: "contains", dataSource: t, select: function(t) { n.apptItem = this.dataItem(t.item)[this.options.dataValueField] || null } }) }) };
            (function() { n.switchMode = lt;
                n.getPersonChangeDate = rt;
                n.getDepartmentChangeDate = ut;
                n.openOfficeGroupTestMultDialog = ft;
                n.date = {};
                n.isSearchTrigger = !1;
                n.dealDealAmount = {};
                n.person = {};
                n.onSearch = ht;
                n.handleDropdownSelect = ct;
                n.isGroup = f.isGroup;
                st();
                n.$on("level", function(t) { n.level = t.targetScope.level; switch (n.level) {
                        case 0:
                            r("#personalPerformance", 160, "person", d, "personPerformanceData", "个人绩效.xlsx"); break;
                        case 1:
                            n.isSearchTrigger = !1;
                            r("#departmentPerformance", 90, "depart", w, "departmentPerformanceData", "部门绩效.xlsx"); break;
                        case 2:
                            n.isSearchTrigger = !1;
                            n.isAllDepartment = !0;
                            r("#departmentPerformance", 90, "depart", w, "departmentPerformanceData", "全部绩效.xlsx") } });
                n.$emit("needRefreshLevel", null) })() } } }]);
dashboardModule.directive("customerServiceDashboardPendingApptView", ["$log", "$q", "$timeout", "$filter", "$modal", "$rootScope", "$window", "aresSlidePanel", "appNav", "appointmentSvc", "dataDicSvc", "dashboardSvc", "gridOptionUtil", "localCache", "loginContext", "patientUtil", "multiOfficeDataDic", "permissionProvider", "aresNotification", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k) { return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-pending-appt-view.html", scope: {}, controller: "CustomerServiceDashboardPendingApptCtrl", link: function(n, t) { var s = null,
                g = v.getCache(v.keys.PendingApptColumnOption),
                h = g.loadObject();
            h = _.isArray(h) ? h : []; var c = Ares.kendoGridUtil(e, n),
                i, lt = [new Ares.Pair(1, "明天"), new Ares.Pair(2, "后天"), new Ares.Pair(3, "大后天"), new Ares.Pair(0, "自定义"), ],
                nt = function() { var n = this,
                        i = n.element;
                    $(t).find("#pendingList tbody tr td a").each(function() { $(this).bind("click", function(n) { var t = $(this).attr("data-patient-id");
                            t && tt(t, n) }) });
                    $(t).find("#pendingList table tbody tr").each(function(t, i) { var r = n.dataItem(i);
                        (r.isCheckedIn || r.isConfirmed || !b.isEditAllApptAllowed && r.createdUserId != y.userId) && $("td .edit-command", i).attr("disabled", !0) }) },
                tt = function(t) { var i = o.open("<customer-details-view><\/customer-details-view>", "CustomerDetailsCtrl", { host: function() { return { patientId: t } } }, n, !0);
                    i.result.then(function() {}) },
                it = [{ field: "patientName", title: "姓名", width: "100px", locked: !0, template: "<div class='double-line-text' title='#: patientId #'><a data-patient-id ='#: patientId #'>#: patientName #<\/a><\/div>" }, { field: "privateId", title: "病历号", width: "100px" }, { field: "tagStr", title: "我的标签", width: "100px" }, { field: "mobile", title: "手机", width: "120px" }, { field: "appointmentType", title: "预约类型", width: "100px" }, { field: "recordCreatedTimeStr", title: "创建时间", width: "120px" }, { field: "officeName", title: "预约门店", width: "120px" }, { field: "startTimeStr", title: "到店时间", width: "100px" }, { field: "doctorName", title: "预约医生", width: "120px" }, { field: "checkInType", title: "就诊类型", width: "120px" }, { field: "transactionNameStr", title: "预约项目", width: "120px", attributes: { "class": "td-class" } }, { field: "stateStr", title: "预约状态", width: "120px" }, { field: "createdUser", title: "创建人", width: "120px" }, { field: "notes", title: "备注", width: "150px", attributes: { "class": "td-span-class" }, template: "<span title='#: notes #'>#: notes #<\/span>" }],
                r = function() { n.search().then(function(n) { columnsListCpy = angular.copy(it);
                        columnsListCpy.push({ field: "", template: c.commandTemplate, title: "操作", width: "200px", index: 300 });
                        i = t.find("#pendingList");
                        i.html(""); var r = e.innerHeight - 180;
                        i = i.kendoGrid({ excel: { allPages: !0 }, dataSource: { data: n.items }, height: r, model: { id: "id" }, columns: columnsListCpy, dataBound: nt, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !0, columnMenuInit: function(n) { $(n.container).find("ul.k-menu >li:not(.k-columns-item)").remove();
                                $(n.container).find("ul.k-menu >li.k-columns-item >div> ul> li.k-first").hide();
                                n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) } }).data("kendoGrid") }) },
                rt = [{ text: "编辑", action: "update", icon: "iconfont icon-bianji", className: "edit-command" }, { text: "新建回访", action: "revisit", icon: "iconfont icon-xinjianhuifang", "class": "new-revisit-command" }, ],
                ut = function(t) { return _.find(n.pageData.items, function(n) { return t == n.id }) },
                ft = function(t, i, r) { var u = ut(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                n.editAppt(r); break;
                            case "revisit":
                                n.createRevisit(u) } }) },
                et = function() { if (i) { var t = { criteria: n.searchCriteria, columns: i.columns };
                        l.exportOnlineConsultAppts(t) } },
                a = function() { n.getCurrentOfficeWorkProviders().then(function(i) { var r = angular.copy(i);
                        r.splice(0, 0, { userID: "0", name: "全部创建人" });
                        s ? s.dataSource.data(r) : s = t.find("#groupOnlineConsultantInput").kendoNameCodeFilterDropDownList({ filter: "contains", dataTextField: "name", dataValueField: "userID", dataSource: r, select: function(t) { n.selectedUserId = this.dataItem(t.item)[this.options.dataValueField] || 0 } }).data("kendoNameCodeFilterDropDownList") }) },
                ot = function() { var i = angular.copy(n.selectedIdsStr),
                        r = angular.copy(n.selectedNamesMulti),
                        f = u.open({ animation: !0, backdrop: "static", template: "<office-group-dialog-view><\/office-group-dialog-view>", controller: "OfficeGroupDialogCtrl", windowClass: "office-group-dialog", resolve: { host: function() { return { selectMode: "multi", selectScope: "office", selectedIds: i, selectedNames: r } } } });
                    f.result.then(function(i) { if (i && i.selectedIds) { n.selectedNamesMulti = i.selectedNames;
                            n.selectedIdsStr = i.selectedIds; var r = i.selectedIds.split(","),
                                u = 0;
                            r && (u = r.length);
                            u == 1 ? (n.isShowTransactionItem = !0, n.selectedOfficeId = r[0], a(), d()) : (n.isShowTransactionItem = !1, n.selectedOfficeId = null, n.transactionCodeNames = null, n.transactionCodeIds = null) } else n.selectedNamesMulti = "", n.selectedIdsStr = "", n.isShowTransactionItem = !1, n.selectedOfficeId = null;
                        t.find("#checkInTypeInput").val("全部就诊类型");
                        t.find("#checkInTypeInput").data("kendoDropDownList").select(0);
                        n.transactionCodeNames = null;
                        n.transactionCodeIds = null }) };
            n.$on("level", function(n, t) { f.level = t;
                r() }); var st = function() { p.createGroupFollowUpAppt().then(function() { k.success("预约成功");
                        r() }) },
                d = function() { var t = n.isGroup ? n.selectedOfficeId : y.officeId; if (t) w.loadDic(t, "systemsettingDic").then(function(t) { var i = _.filter(t, function(n) { return n.itemType == "就诊类型" });
                        i.unshift({ itemName: "全部就诊类型" });
                        n.checkInTypes = i });
                    else return },
                ht = function() { return t.find("#checkInTypeInput").val() },
                ct = function() { n.searchMode = !n.searchMode;
                    n.searchMode || (n.transactionCodeNames = null, n.transactionCodeIds = null, t.find("#checkInTypeInput").val("全部就诊类型"), t.find("#checkInTypeInput").data("kendoDropDownList").select(0), n.selectedUserId = -1, n.apptState = 0, n.isFirstVisit = -1) };
            (function() { n.switchMode = ct;
                n.exportExcel = et;
                n.refreshGrid = r;
                n.createAppt = st;
                n.getCheckInType = ht;
                n.isShowTransactionItem = !1;
                n.selectedNamesMulti = null;
                n.selectedIdsStr = null;
                n.commands = rt;
                n.onCommandClick = ft;
                n.openOfficeGroupMultDialog = ot;
                a();
                d();
                r();
                n.$on("$destroy", function() { c.dispose() }) })() } } }]);
dashboardModule.directive("customerServiceDashboardReportHomeView", ["$log", "$timeout", "$state", "$location", "appNav", "moduleOptionProvider", "officeOptionSvc", "dataDicSvc", "localCache", function(n, t, i, r, u, f, e, o) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-report-home-view.html", link: function(n) { var t = function(t) { var r = [new u.TabItem("dashBoard.groupCustomerReportHome.groupCustomerMyPerformance", "业绩统计", "icon-users", null), ];
                    f.isPaymentTypeUpgradeEnabled() && i(r, t, "dashBoard.groupCustomerReportHome.onlineConsultPerformanceSet", "OnlineConsultPerformanceSet");
                    f.isDelunCustomFeatureOpen() && r.push(new u.TabItem("dashBoard.groupCustomerReportHome.groupConsultQuantities", "咨询量", "icon-users", null));
                    n.states = r },
                i = function(n, t, i, r) { var f = _(t).find(function(n) { return n.name == r }),
                        e;
                    f && f.reports && f.reports.length > 0 && (e = null, _(f.reports).every(function(n) { return n.permissionCode }) && (e = _(f.reports).pluck("permissionCode").join("|")), n.push(new u.TabItem(i, f.displayName, "", e))) };
            (function() { o.reportSetConfigDic.load().then(function(n) { t(n) }) })() } } }]);
dashboardModule.directive("customerServiceDashboardReportv2View", ["$log", "$timeout", "$state", "$location", "appNav", "moduleOptionProvider", "officeOptionSvc", "dataDicSvc", "localCache", function() { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-reportv2-view.html", controller: "CustomerServiceDashboardReportv2Ctrl", link: function(n) {
            (function() { n.level = 0;
                n.$on("level", function(t) { n.level = t.targetScope.level });
                n.$emit("needRefreshLevel", null) })() } } }]);
dashboardModule.directive("customerServiceDashboardRevisitPlanView", ["$log", "$window", "$modal", "$timeout", "$q", "patientUtil", "kendoUtil", "enums", "dataDicSvc", "loginContext", "aresDialog", "aresNotification", "revisitSvc", "aresSlidePanel", "officeOptionSvc", "aresModalShelf", "localCache", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w) { return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-revisit-plan-view.html", controller: "CustomerServiceDashboardRevisitPlanCtrl", link: function(n, i) { var b = i.find(".groupOnlineConsultantInput"),
                it = Ares.kendoGridUtil(t, n),
                rt = function() { s.revisitorDic.loadActive().then(function(t) { t = f.filterProviderByPatientPermissionLevel(t);
                        t = _.filter(t, function(n) { return n.show });
                        b = b.kendoDropDownList({ dataSource: t, optionLabel: "全部回访人", dataTextField: "name", dataValueField: "id", filter: "contains", select: function(t) { n.visitorId = this.dataItem(t.item)[this.options.dataValueField] || -1;
                                o(!0);
                                Ares.sensors.track("CustomerServiceDashboardRevisitPlan", { OperationType: "回访人:" + this.dataItem(t.item)[this.options.dataTextField] }) } }) }) },
                ut = function() { s.revisitTypeDic.load().then(function(t) { n.revisitTypes = t; var r = i.find("#revisitType").kendoDropDownList({ dataSource: t, optionLabel: "全部回访类型", dataTextField: "itemName", dataValueField: "itemName", filter: "contains", select: function(t) { n.revisitType = this.dataItem(t.item)[this.options.dataValueField] || null;
                                o(!0);
                                Ares.sensors.track("CustomerServiceDashboardRevisitPlan", { OperationType: "回访类型:" + this.dataItem(t.item)[this.options.dataTextField] }) } }) }) },
                nt = function() { n.searchStatus == "-1" ? n.revisitState = "0,1,2" : n.searchStatus == "0" && (n.revisitState = "1,2");
                    n.searchStatus == "1" ? n.revisitState = "0" : n.searchStatus == "2" ? n.revisitState = "1" : n.searchStatus == "3" && (n.revisitState = "2");
                    o(!0); var t = w.getCache(w.keys.CustomerServiceDashboardRevisitPlan);
                    n.cachedUiState.searchStatus = n.cachedUiState.searchStatus || {};
                    n.cachedUiState.searchStatus[h.userId] = n.searchStatus;
                    t.saveObject(n.cachedUiState) },
                ft = function() { s.transactionCodeDic.load().then(function(t) { if (t) var r = i.find("#transactions").kendoDropDownList({ dataSource: t, optionLabel: "全部回访项目", dataTextField: "name", dataValueField: "id", filter: "contains", select: function(t) { n.transactionId = this.dataItem(t.item)[this.options.dataValueField] || null;
                                o(!0);
                                Ares.sensors.track("CustomerServiceDashboardRevisitPlan", { OperationType: "回访项目:" + this.dataItem(t.item)[this.options.dataTextField] }) } }) }) },
                et = function() { var t = this,
                        r = t.element,
                        n;
                    $(i).find("#revisitPlanGrid table tbody tr").each(function(n, r) { var u = t.dataItem(r);
                        u.state == "待计划" ? u.visitorId == h.providerId && u.recordCreatedUser != h.userId ? i.find(r).find("td .edit-command").remove() : u.visitorId != h.providerId && u.recordCreatedUser == h.userId && i.find(r).find("td .execute-command").remove() : i.find(r).find("td .execute-command").remove() });
                    $(i).find("#revisitPlanGrid tbody tr td a").each(function() { $(this).bind("click", function(n) { var t = $(this).attr("data-patient-id");
                            t && pt(t, n) }) });
                    n = i.find("#revisitPlanGrid .k-grid-content table");
                    n.width() < n.parent().width() && n.width("100%").find("colgroup col:last").width("auto") },
                ti = function() { var t = i.find("#revisitState").kendoDropDownList({ dataSource: [{ name: "全部回访状态", value: -1 }, { name: "待计划", value: 0 }, { name: "已完成", value: 1 }, { name: "未成功", value: 2 }, { name: "已取消", value: 3 }, ], dataTextField: "name", dataValueField: "value", template: "#: name # ", valueTemplate: "#: name #", select: function(t) { var i = this;
                            r(function() { n.revisitState = i.dataItem(t.item)[i.options.dataValueField];
                                o(!0) });
                            Ares.sensors.track("CustomerServiceDashboardRevisitPlan", { OperationType: "回访状态:" + this.dataItem(t.item)[this.options.dataTextField] }) } }).data("kendoDropDownList") },
                ot = function() { n.columns = [{ field: "patientName", title: "患者姓名", width: "100px", locked: !0, template: "<div class='double-line-text' title='#: patientId #'><a data-patient-id ='#: patientId #'>#: patientName #<\/a><\/div>" }, { field: "privateId", title: "病历号", width: "110px" }, { field: "mobile", title: "手机号", width: "110px" }, { field: "visitorName", title: "回访人", width: "110px" }, { field: "department", title: "回访人科室", width: "110px" }, { field: "planTime", title: "计划时间", width: "110px", template: function(n) { return e.datetimeFormat(n.planTime) } }, { field: "visitTime", title: "回访时间", width: "110px", template: function(n) { return e.datetimeFormat(n.visitTime) } }, { field: "method", title: "沟通方式", width: "110px" }, { field: "type", title: "回访类型", width: "110px" }, { field: "transactionItems", title: "回访项目", width: "110px" }, { field: "content", title: "回访内容", width: "110px" }, { field: "lastVisit", title: "最近就诊时间", width: "110px", template: function(n) { return e.datetimeFormat(n.lastVisit) } }, { field: "state", title: "回访状态", width: "110px" }, { field: "notes", title: "回访备注", width: "110px" }, { field: "satisfaction", title: "满意度", width: "110px" }, ];
                    n.level != 2 && (n.columns = _.filter(n.columns, function(n) { return n.field != "department" })); var t = u.defer(),
                        i = h.officeId,
                        r = y.optionKeys.OnlineConsultCreateInfoFieldsConfig; return y.getOfficeOptionByOfficeId(r, i).then(function(i) { var r = y.optionDefaultValues.OnlineConsultCreateInfoFieldsDefaultConfig,
                            u;
                        i && (r = _.isString(i) ? JSON.parse(i) : i);
                        u = _.filter(r, function(n) { return !n.isEnabled });
                        n.columns = _.filter(n.columns, function(n) { var t = n.field,
                                i; switch (t) {
                                case "notes":
                                    t = "revisitNotes"; break;
                                case "transactionItems":
                                    t = "revisitItems" } return i = _.find(u, function(n) { return t == n.name }), i === undefined });
                        t.resolve() }), t.promise },
                k = null,
                d, o = function(r) { n.refreshRevisitPlan(r).then(function(r) { var f, e, u;
                        k = angular.copy(n.columns);
                        k.push({ template: it.commandTemplate, title: "操作", width: "126px", index: 200 });
                        f = i.find("#revisitPlanGrid");
                        f.html("");
                        e = t.innerHeight - 210;
                        u = "个人";
                        n.level == 1 ? u = "部门" : n.level == 2 && (u = "全部");
                        d = f.kendoGrid({ excel: { allPages: !0, fileName: u + "咨询列表.xlsx" }, dataSource: { data: r.items }, height: e, model: { id: "id" }, columns: k, dataBound: et, sortable: !1, resizable: !0, reorderable: !0, columnMenu: !1, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) } }).data("kendoGrid") }) },
                st = function() { d && d.saveAsExcel() },
                ht = function() { var t = moment(Ares.today()).format("YYYY-MM-DD"),
                        i = moment(Ares.tomorrow()).format("YYYY-MM-DD");
                    n.startDate = t;
                    n.endDate = i;
                    n.revisitTimes = { startDate: t, endDate: t } },
                g = function() { n.visitorId = n.level == 0 ? h.providerId : -1;
                    b.val(n.visitorId);
                    rt();
                    ut();
                    ft();
                    ht();
                    ot().then(function() { o() }) },
                ct = function(t) { return _.find(n.pageData.items, function(n) { return n.id == t }) },
                lt = [{ text: "编辑", action: "update", className: "edit-command", showText: !0 }, { text: "执行", action: "execute", className: "execute-command", showText: !0 }, { text: "删除", action: "delete", className: "delete-command", showText: !0 }, ],
                at = function(t, i, r) { var u = ct(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                var n = u.state == "待计划" ? !0 : !1;
                                tt(u, n, "修改回访"); break;
                            case "execute":
                                tt(u, !1, "执行回访"); break;
                            case "delete":
                                wt(u.id) } }) },
                vt = function(t) { n.pageIndex = t;
                    o() },
                yt = function(t) { n.pageSize = t;
                    o() },
                pt = function(t) { var i = v.open("<customer-details-view><\/customer-details-view>", "CustomerDetailsCtrl", { host: function() { return { patientId: t } } }, n, !0);
                    i.result.then(function() {}) },
                tt = function(n, t, i) { var r = p.open({ title: i, template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return { patientId: n.patientId, revisitId: n.id, isRevisitTask: t, isEdit: !0 } } } });
                    r.result.then(function() { o(!0) }) },
                wt = function(n) { c.confirm("信息", "确定要删除吗！").then(function() { a.deleteRevisit(n).success(function() { l.success("删除成功！");
                            o() }) }) },
                bt = function(t) { n.startDate = t.startDate;
                    n.endDate = moment(t.endDate).add(1, "day").format("YYYY-MM-DD") },
                kt = function(n) { bt(n);
                    o(!0) },
                ii = function() { g();
                    n.getOnlineConsultRevisitTimes() };
            n.$on("level", function(t, i) { n.level = i;
                g() }); var dt = function() { var t = v.open("<revisit-detail-edit-view><\/revisit-detail-edit-view>", "RevisitDetailEditCtrl", { host: function() { return { title: "新建回访", isNewRevivit: !0 } } }, n);
                    t.result.then(function() { o(!0) }) },
                gt = function() { var n = p.open({ title: "新增回访", template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return { needSearchPatient: !0, isEdit: !1, isRevisitTask: !1 } } } });
                    n.result.then(function() { o(!0) }) },
                ni = function() { var t = w.getCache(w.keys.CustomerServiceDashboardRevisitPlan);
                    n.cachedUiState = t.loadObject();
                    n.searchStatus = angular.isUndefined(n.cachedUiState.searchStatus) || n.cachedUiState.searchStatus === null || angular.isUndefined(n.cachedUiState.searchStatus[h.userId]) ? "1" : n.cachedUiState.searchStatus[h.userId];
                    nt() };
            (function() { n.commands = lt;
                n.onCommandClick = at;
                n.searchByDays = kt;
                ni();
                g();
                n.onPageChanged = vt;
                n.onPageSizeChanged = yt;
                n.onSearchStatusChange = nt;
                n.createRevisit = dt;
                n.createRevisitTask = gt;
                n.exportExcel = st })() } } }]);
dashboardModule.directive("customerServiceDashboardWorkbenchView", ["$log", "$q", "$timeout", "$window", "eventAggregator", "$modal", "$rootScope", "dataDicSvc", "aresNotification", "loginContext", "patientSvc", "dashboardSvc", "inventoryProductSvc", "organizationSvc", "gridOptionUtil", "aresSlidePanel", "customerServiceUtil", "kendoUtil", "patientUtil", "enums", "appNav", "moduleOptionProvider", "officeSelectorUtil", "aresModalShelf", "localCache", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt, tt, it, rt) { return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/customer-service/customer-service-dashboard-workbench-view.html", controller: "CustomerServiceDashboardWorkbenchCtrl", link: function(n, t) { var bt = function(t, i, r, u, f) { var e = t.element.kendoDropDownList({ autoBind: !0, dataTextField: i, dataValueField: r, valuePrimitive: !0, optionLabel: "请选择", dataSource: u }).data("kendoDropDownList");
                    f == "sourceTypeOne" && (n.sourceTypeOneDropdown = e);
                    f == "sourceTypeTwo" && (n.sourceTypeTwoDropdown = e);
                    f == "sourceTypeThree" && (n.sourceTypeThreeDropdown = e) },
                kt = function(n) { var t = n.element.kendoDateTimePicker({ autoBind: !0, format: "yyyy-MM-dd HH:mm", culture: "zh-CN" }).data("kendoDateTimePicker") },
                o = function() { var u = angular.element(r).height(),
                        i = u - 275; return n.uiState.isAdvancedSearchOpen && (i = i - t.find(".search-form-advanced").height() - 10), n.gridInstance && n.gridInstance.setOptions({ height: i }), i },
                d = function() { var r = a(),
                        i, u;
                    n.fixedColumns = r.slice(0, 2);
                    n.showColumns && n.showColumns.length > 0 && y.formatColumns(r, n.showColumns);
                    i = r.slice(2);
                    i = _.sortBy(i, "index");
                    n.isDefaultCustom || _.each(i, function(n) { n.hidden = !1;
                        n.isShow = !0 });
                    u = t.find("#customerServiceList");
                    u.kendoGrid({ resizable: !1, columnResizeHandleWidth: 20, reorderable: !1, sortable: !1, height: o(), columns: n.fixedColumns.concat(i), columnMenu: !1, dataBound: g });
                    n.gridInstance = u.data("kendoGrid") },
                g = function() { var i = this.dataSource.data();
                    $(t).find("#customerServiceList tbody tr td a").each(function() { $(this).bind("click", function(n) { var t = $(this).attr("data-patient-id");
                            t && tt(t, n) }) });
                    $(t).find("#customerServiceList table .check-all").each(function() { $(this).bind("click", function(t) { var i = b.selectAllRow(n.gridInstance, "customerServiceList", t);
                            e(i);
                            n.selectTotalCount = t.currentTarget.checked ? n.selectTotalCount : !1 }) });
                    $(t).find("#customerServiceList table tbody tr td .commonColumns_sub_checkbox").each(function() { $(this).bind("click", function(t) { var i = b.selectSingleRow(n.gridInstance, "customerServiceList", n.patientList.items.length, this, t);
                            e(i);
                            n.selectTotalCount = t.currentTarget.checked ? n.selectTotalCount : !1 }) });
                    $(t).find("#customerServiceList thead tr th .k-button").each(function() { $(this).bind("click", function() { var n = $(this).siblings("span").find("input");
                            n.each(function() { $(this).val("") }) }) }) },
                e = function(t) { i(function() { n.selectedRows = t }) },
                a = function() { var t = angular.copy(w.customerServiceColumn),
                        i; return h.isGroup || (t = t.filter(function(n) { return n.title != "所属机构" })), i = b.CommonColumns.checkboxColumn, i.locked = !0, t.splice(0, 0, i), n.showColumns.length > 0 ? angular.forEach(t, function(t) { var i = _.find(n.showColumns, function(n) { return n === t.field });
                        t.hidden = !i;
                        t.isShow = !t.hidden }) : _.each(t, function(n) { n.isShow = !n.hidden }), t },
                v = function(t) { n.showColumns = t },
                k = function(t) { n.selectType = t;
                    n.onSearch(); var i = ["全部客户", "今日咨询", "今日待回访", "昨日失约", "昨日成交人数", "昨日未成交", "今日预约人数", "今日到店人数", "今日成交人数", "线索客户"][t];
                    Ares.sensors.track("CustomerServiceDashboardWorkbench", { OperationType: i == undefined ? t : i }) },
                nt = function() { var r = t.find("#customerServiceList");
                    n.onSearch().then(function() { i(function() { var t = r.find(".check-all");
                            t.prop("checked", !1);
                            e(0);
                            n.selectTotalCount = !1 }) }) },
                tt = function(t) { var i = p.open("<customer-details-view><\/customer-details-view>", "CustomerDetailsCtrl", { host: function() { return { patientId: t } } }, n, !0);
                    i.result.then(function() {}) },
                ut = function() { n.getOnlineConsultSumData() };
            n.$on("level", function(t, i) { n.level = i;
                i || (n.searchCriteriaModel.onlineConsultantId = null);
                n.getOnlineConsultSumData().then(function() { k(n.selectType) }) });
            n.$on("customerRegistration", function(t, i) { i && n.onSearch() }); var u = function() { var i = b.getCustomSelectedData(n.gridInstance),
                        t = []; return i.forEach(function(n) { t.push(n.patientId) }), t = _.uniq(t) },
                ft = function(i) { var r = t.find("#customerServiceList"),
                        u = r.find(".check-all"),
                        f;
                    u.prop("checked", i);
                    f = b.selectAllRow(n.gridInstance, "customerServiceList", i);
                    n.totalCount = i ? n.patientList.totalCount : 0;
                    n.selectedRows = angular.copy(n.totalCount) },
                et = function() { var n = u() },
                ot = function() { var t = { patientIds: u(), criteria: null },
                        i; if (n.selectTotalCount) t.patientIds = null, t.criteria = n.getSearchCriteria(), t.patientCount = n.patientList.totalCount;
                    else { if (!t.patientIds || t.patientIds.length <= 0) { s.error("请选择患者"); return } t.patientCount = t.patientIds.length } i = f.open({ animation: !0, backdrop: "static", template: "<update-multi-customer-property-view><\/update-multi-customer-property-view>", controller: "UpdateMultiCustomerPropertyCtrl", windowClass: "width-500-dialog", backdropClass: "inventory-modal-backdrop", resolve: { host: function() { return t } } });
                    i.result.then(function(t) { t && n.onSearch() });
                    Ares.sensors.track("CustomerServiceDashboardWorkbench", { OperationType: "批量修改客户关系" }) },
                st = function() { var n = u() },
                ht = function(t) { if (t !== "全部" && t) { var i = _.find(n.sourceTypeData, function(n) { return n.sourceName === t && n.level === 1 });
                        i ? (n.sourceTypeTwoData = n.sourceTypeData.filter(function(n) { return i.id === n.parentId && n.level === 2 }).map(function(n) { return { itemName: n.sourceName } }), n.sourceTypeTwoData.unshift({ itemName: "全部" })) : n.sourceTypeTwoData = [{ itemName: "全部" }] } else n.sourceTypeTwoData = [{ itemName: "全部" }];
                    n.sourceTypeThreeData = [{ refereeName: "全部" }];
                    n.searchCriteriaModel.sourceTypeTwo = "全部";
                    n.searchCriteriaModel.sourceTypeThree = "全部" },
                ct = function(t) { n.searchCriteriaModel.sourceTypeOne != "" && t != "" ? c.searchRefereeNames(t).success(function(t) { n.sourceTypeThreeData = t; var i = _.filter(n.sourceTypeThreeData, function(n) { return n.refereeName === "全部" });
                        i.length == 0 && n.sourceTypeThreeData.unshift({ refereeName: "全部" }) }) : n.sourceTypeThreeData = [{ refereeName: "全部" }];
                    n.searchCriteriaModel.sourceTypeThree = "全部" },
                lt = function() { var t = _.filter(angular.copy(n.gridInstance.columns), function(n) { return !!n.field }),
                        i = _.find(t, { field: "patientName" }),
                        r;
                    i && (i.title = "患者姓名");
                    r = { criteria: n.getSearchCriteria(), columns: t };
                    l.exportOnlineConsultPatientsNew(r) },
                at = function(n, i) { var r = kendo.observable({ value: n });
                    kendo.bind(t.find(i), r) },
                vt = function() { var t = { isRevisitTask: !1, isBatchRevisit: !0, patientIds: u(), criteria: null },
                        i; if (n.selectTotalCount) t.patientIds = null, t.criteria = n.getSearchCriteria(), t.patientCount = n.patientList.totalCount;
                    else { if (!t.patientIds || t.patientIds.length <= 0) { s.error("请选择患者"); return } t.patientCount = t.patientIds.length } i = it.open({ title: "新增回访", template: "<customer-revisit-edit-modal-view><\/customer-revisit-edit-modal-view>", controller: "CustomerRevisitEditModalCtrl", resolve: { host: function() { return t } } });
                    i.result.then(function() {}) },
                yt = function(t) { t === 2 ? ht(n.searchCriteriaModel.sourceTypeOne) : t === 3 && ct(n.searchCriteriaModel.sourceTypeTwo) },
                pt = function(t) { var r = t[0],
                        i, u, f;
                    n.isDefaultCustom = r.isCustom;
                    i = r.optionColumns;
                    _.each(i, function(n) { n.hidden = !n.isShow });
                    n.gridInstance.setOptions({ columns: n.fixedColumns.concat(i) });
                    r.isCustom ? y.updateColumnsOption(n.gridOptionKey, i, v) : (u = angular.copy(i), _.each(u, function(t) { t.isShow = !!_.find(n.showColumns, function(n) { return n === t.field });
                        t.hidden = !t.isShow }), y.updateColumnsOption(n.gridOptionKey, u, v));
                    f = rt.getCache(rt.keys.CustomerServiceDashboardWorkbenchCustomColumn);
                    f.saveValue(r.isCustom) },
                wt = function() { var i = a(),
                        t;
                    n.showColumns && n.showColumns.length > 0 && y.formatColumns(i, n.showColumns);
                    t = i.slice(2);
                    t = _.sortBy(t, "index");
                    n.filterableColumnGroups = [{ name: "main", state: "main", optionColumns: angular.copy(t), isCustom: !!n.isDefaultCustom }] };
            (function() { n.onAllCheckboxClicked = ft;
                n.onPaginationChanged = nt;
                n.sendMessage = et;
                n.editCustomerRelationship = ot;
                n.exportSelected = st;
                n.tabChange = k;
                n.createRevisits = vt;
                ut();
                n.sourceTypeOneData = [{ itemName: "全部" }];
                n.sourceTypeTwoData = [{ itemName: "全部" }];
                n.sourceTypeThreeData = [{ refereeName: "全部" }];
                n.exportExcel = lt;
                n.setEndDate = at;
                n.refreshSourceTypeData = yt;
                n.setGridHeight = o;
                n.onColumnConfigSave = pt;
                n.onColumnConfigExpand = wt;
                n.initData().then(function() { d();
                    n.onSearch() }) })() } } }]);
dashboardModule.directive("apptContentView", ["$log", "$timeout", "$filter", "officeSvc", "$q", "officeSelectorUtil", "loginContext", "multiOfficeDataDic", "schedulerUtil", "officeOptionSvc", "providerSvc", "eventAggregator", "dataDicSvc", "localCache", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/components/appt-content/appt-content-view.html", scope: { source: "=", isApptEnabled: "=" }, link: function(n, t) { var p = v.getCache(v.keys.CustomerRegistrationApptEnable),
                l, c, d = i("toOfficeAbbr"),
                g = function(t) { n.timeUnits = 1; var i = s.loadSchedulerConfigSync();
                    n.timeSlotUnit = i ? i.timeSlotUnit : 15;
                    t ? (b([]), r.getSelfAndChildOfficesByGroupId(e.officeId, !1).success(t => { n.officeTreeData = f.setId(t) })) : (n.source.doctorId = null, n.source.officeId = e.officeId, n.isDisabled = !1, w().then(function() { l.enable(!0) }), y().then(function() { c.enable(!0) }));
                    rt();
                    ut() },
                nt = function() {!n.source || n.source.endTime || n.source.isPending || a() },
                a = function() { var t = n.timeUnits * n.timeSlotUnit,
                        i = moment(n.source.startTime).add(t, "m").format("YYYY-MM-DD HH:mm:ss");
                    n.source.endTime = i },
                tt = function(t) { n.selectedOfficeIdsArray = _.pluck(t, "officeId");
                    n.source.doctorId = null;
                    n.source.officeId = n.selectedOfficeIdsArray[0];
                    n.source.officeId && (n.isDisabled = !1, w().then(function() { l.enable(!0) }), y().then(function() { c.enable(!0) })) },
                w = function() { var t = u.defer(); return o.loadDic(n.source.officeId, "doctorDic").then(function(n) { n = n.filter(function(n) { return n.show && !n.isInactive });
                        b(n);
                        t.resolve(!0) }), t.promise },
                b = function(i) { l ? l.setDataSource(i) : l = t.find("#provider").kendoNameCodeFilterDropDownList({ optionLabel: "请选择预约医生", dataSource: i, dataTextField: "name", dataValueField: "id", enable: !1, filter: "contains", change: function(t) { var i = t.sender.value();
                            n.source.doctorId = i } }).data("kendoNameCodeFilterDropDownList") },
                y = function() { var t = u.defer(); return o.loadDic(n.source.officeId, "transactionCodeDic").then(function(n) { k(n);
                        t.resolve(!0) }), t.promise },
                k = function(i) { c ? c.setDataSource(i) : c = t.find("#transactionCode").kendoMultiSelect({ maxSelectedItems: 10, dataTextField: "name", dataValueField: "id", enable: !1, dataSource: i, change: function(t) { n.source.procedures = []; var i = t.sender.value();
                            angular.forEach(i, t => { n.source.procedures.push({ transactionId: t }) }) } }).data("kendoMultiSelect") },
                it = function() { n.source.isPending = !n.source.isPending;
                    p.saveValue(n.isApptEnabled);
                    n.source.isPending || (a(), n.source.officeId > 0 ? y().then(function() { c.enable(!0) }) : k([])) },
                rt = function() { n.appointmentSource = { appointmentId: 0, sourceLevel1: "", sourceLevel2: "", sourceLevel3: "", sourceRefereeId: 0 };
                    n.source.appointmentSource = n.appointmentSource },
                ut = function() { var t = u.defer(); return h.getOfficeOption(h.optionKeys.IsAppointmentSourceEnabled).then(function(i) { n.isAppointmentSourceEnabled = i;
                        t.resolve() }), t.promise },
                ft = function() { n.$watch("source.startTime", function() { n.source && n.source.startTime && !n.source.isPending && n.setEndTime() }) };
            (function() { var i, t;
                n.onConfigSwitch = it;
                n.onOfficeSelected = tt;
                n.selectedOfficeIdsArray = [];
                n.isDisabled = !0;
                i = Ares.today();
                n.prohibitBeforeToday = i;
                n.defaultTime = moment(new Date).add(1, "d").format("YYYY-MM-DD") + " 10:00";
                n.hideSearch = !0;
                n.setDefaultEndTime = nt;
                n.setEndTime = a;
                n.isGroup = e.isGroup;
                n.officeName = d(e.officeId);
                t = p.loadValue();
                t && (n.isApptEnabled = JSON.parse(t), n.source.isPending = n.isApptEnabled);
                ft();
                g(n.isGroup) })() } } }]);
dashboardModule.directive("consultationContentView", ["$log", "dataDicSvc", "$q", "patientUtil", function(n, t, i, r) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/components/consultation-content/consultation-content-view.html", scope: { source: "=" }, link: function(n, u) { var f, c = function() { l();
                    h();
                    e();
                    o();
                    s() },
                l = function() { var i = "(1).病情主诉：\n(2).适合回访时间：\n(3).倾向专家：\n(4).其他：";
                    t.systemItemDic.loadActive({ itemType: "咨询内容模板" }).then(function(t) { n.source.content = t && t.length > 0 ? t[0].itemValue.replace(/\\n/g, "\n") : i }) },
                e = function() { var r = i.defer(); return t.communicationMethodDic.load().then(function(t) { n.visitMethods = t;
                        r.resolve() }), r.promise },
                o = function() { t.systemItemDic.loadActive({ itemType: "成交意愿" }).then(function(t) { n.intentions = t }) },
                s = function() { t.systemItemDic.loadActive({ itemType: "意向说明" }).then(function(t) { n.intentionDescs = t; var i = n.source.intentionDesc ? n.source.intentionDesc : "请选择意向说明";
                        u.find("#intentionDescInput").data("kendoDropDownList").wrapper.attr("title", i) }) },
                h = function() { t.consultItemDic.load().then(function(t) { f ? f.dataSource.data(t) : f = u.find("#consultItems").kendoMultiSelect({ placeholder: "请选择咨询项目", dataTextField: "itemName", dataValueField: "itemName", valuePrimitive: !0, autoBind: !1, filter: "contains", dataSource: t, separator: ",", change: function(t) { var i = t.sender.value();
                                i && i.length > 0 ? (n.source.consultItems = i.join(), i[0] == "" && (n.source.consultItems = n.source.consultItems.substr(1))) : n.source.consultItems = "" } }).data("kendoMultiSelect") }) },
                a = function() { var n = r.editSysitemContent("沟通方式");
                    n.result.then(function() { t.communicationMethodDic.clearCache();
                        e() }) },
                v = function() { var n = r.editSysitemContent("咨询项目");
                    n.result.then(function() { t.consultItemDic.clearCache();
                        h() }) },
                y = function() { var n = r.editSysitemContent("成交意愿", !0);
                    n.result.then(function() { o() }) },
                p = function() { var n = r.editSysitemContent("意向说明", !0);
                    n.result.then(function() { s() }) },
                w = function(t) { var i = t.sender.value();
                    n.source.intention = i },
                b = function(t) { var r = t.sender.value(),
                        i;
                    n.source.intentionDesc = r;
                    i = n.source.intentionDesc ? n.source.intentionDesc : "请选择意向说明";
                    t.sender.wrapper.attr("title", i) };
            (function() { n.editRevisitMethod = a;
                n.onIntentionChanged = w;
                n.onIntentionDescChanged = b;
                n.editOnlineConsultItems = v;
                n.editIntentionItems = y;
                n.editIntentionDescs = p;
                c() })() } } }]);
dashboardModule.directive("customerInfoView", ["$log", "$q", "$timeout", "dataDicSvc", "enums", "$modal", "practiceSvc", "baiduAreaSvc", "aresNotification", "patientSvc", "eventAggregator", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/components/customer-info/customer-info-view.html", scope: { patient: "=", mobileList: "=", phoneList: "=", onlineConsultCreateInfoFields: "=", isEnabledConfigField: "&", isRequiredConfigField: "&" }, link: function(n, u) { var v, y = function() { n.patient.familyAddress = {};
                    n.patient.privateTag = {};
                    n.tagStr = "";
                    n.patient.sex = 0;
                    v = n.patient;
                    w();
                    p();
                    k() },
                p = function() { r.patientTagDic.load().then(function(t) { t = _.filter(t, n => n.isInactive == !1);
                        u.find("#patientTag").kendoMultiSelect({ maxSelectedItems: 10, dataTextField: "itemName", dataValueField: "id", dataSource: t, change: function(t) { n.patient.patientTagUseList = []; var i = t.sender.value();
                                angular.forEach(i, t => { n.patient.patientTagUseList.push({ tagId: t }) }) } }) }) },
                w = function() { e.getItemTypes("phoneNumberAttribute").success(function(t) { var i = n.phoneList;
                        t && t.length > 0 && i.length == 0 && n.phoneList.push({ mobileType: t[0].itemName, mobile: "", attributes: "PhoneNumber", displayOrder: 1 });
                        n.phoneNumberTypes = t });
                    e.getItemTypes("mobileAttribute").success(function(t) { var i = n.mobileList;
                        t && t.length > 0 && i.length == 0 && n.mobileList.push({ mobileType: t[0].itemName, mobile: "", attributes: "mobile", displayOrder: 1 });
                        n.mobileNumberTypes = t }) },
                b = function() { r.patientSourceTypeDic.load().then(function(t) { n.patientSourceType = t }) },
                l = function(n, i, r) { var u = t.defer(),
                        f; return r == 2 && (i == "北京市" || i == "天津市" || i == "上海市" || i == "重庆市" || i == "澳门特别行政区" || i == "香港特别行政区") && (f = [{ areaName: i, areaCode: n }], u.resolve(f)), o.getSubBaiduAreas({ areaCode: n, areaType: r }).success(function(n) { u.resolve(n) }).error(function(n) { u.reject(n) }), u.promise },
                k = function() { l(1, "", 1).then(t => { n.provinces = t }) },
                d = function(t, i) { n.patient.familyAddress || (n.patient.familyAddress = {}); var u = t.sender.value(),
                        r = t.sender.text();
                    i ? u ? l(u, r, i).then(t => { i == 2 ? (n.cities = t, n.patient.familyAddress.province = r) : i == 3 && (n.districts = t, n.patient.familyAddress.city = r) }) : i == 2 ? n.patient.familyAddress.province = "" : i == 3 && (n.patient.familyAddress.city = "") : n.patient.familyAddress.district = u ? r : "" },
                g = function() { var t = moment(Ares.today());
                    n.patient.brithType = null;
                    n.patient.age = t.diff(n.patient.birth, "years") },
                nt = function() { tt() || (n.patient.birth = null, n.patient.age = null, s.error("请输入正确的生日")) },
                tt = function() { var t = n.patient.birth.split("-"),
                        i; return t && t.length == 3 && (i = new Date(n.patient.birth), _.isDate(i)) ? (n.patient.birth = moment(n.patient.birth).format("YYYY-MM-DD"), !0) : !1 },
                it = function() { var t = parseInt(n.patient.age),
                        i; if (_.isNaN(t) || !_.isNumber(t)) { n.patient.brithType = null;
                        n.patient.birth = null;
                        n.patient.age = ""; return } n.patient.brithType = 2;
                    i = (new Date).getYear() + 1900;
                    n.patient.birth = parseInt(i) - t + "-01-01" },
                rt = function(t) { if (n.patient.isMobileValid = !0, t && t.mobile)
                        if (/^1[0-9]{10}$/.test(t.mobile)) t.mobileType === "本人" && h.validationPatientMobile(t.mobile).success(t => { if (n.patient.isMobileValid = t, !t) { s.error("患者手机号已存在"); return } });
                        else { s.error("请输入正确的手机号码"); return } },
                ut = function() { var t = n.mobileList,
                        i; if (t.length == 3) { s.error("同个患者最多添加三个手机号码！"); return } if (t[t.length - 1].mobile == "") { s.error("请设置正确的手机号码及属性！"); return } if (t[t.length - 1].mobileType == "") { s.error("请设置正确的手机号码及属性！"); return } i = { mobile: "", patientId: n.patient.id, attributes: "mobile", mobileType: "", displayOrder: t.length + 1 };
                    n.mobileList.push(i) },
                ft = function() { var t = a("手机号码属性");
                    t.result.then(function() { e.getItemTypes("mobileAttribute").success(function(t) { var i, r; for (n.mobileNumberTypes = t, i = 0; i < n.mobileList.length; i++) r = _.find(n.mobileNumberTypes, function(t) { return t.itemName == n.mobileList[i].mobileType }), r || (n.mobileList[i].mobileType = "") }) }) },
                et = function(t) { n.mobileList.splice(t, 1);
                    n.mobileList[n.mobileList.length - 1].displayOrder = n.mobileList.length },
                a = function(n) { return f.open({ animation: !0, backdrop: "static", template: "<system-setting-item-edit><\/system-setting-item-edit>", controller: "SystemSettingItemEditCtrl", resolve: { host: function() { return { itemType: n } }, boxTitle: function() { return "" } } }) },
                ot = function() { i(function() { u.find(".customer-registration-content").find('[data-toggle="tooltip"]').tooltip() }) },
                st = function(t) { var i = t;
                    t == "aresCustomLabel" ? i = "我的标签" : t == "aresPatientSourceType" && (i = "来源渠道");
                    Ares.sensors.track("CustomerRegistration", { OperationType: i });
                    c.publish(c.events.CustomerPatientSourceChanged, n.patient) },
                ht = function() { n.patient.brithType = n.patient.brithType === 2 ? null : 2 },
                ct = function(t) { return n.isRequiredConfigField()(n.onlineConsultCreateInfoFields, t) },
                lt = function(t) { return n.isEnabledConfigField()(n.onlineConsultCreateInfoFields, t) };
            (function() { n.isRequired = ct;
                n.isEnabled = lt;
                n.onNotSureBirthClick = ht;
                n.onAreaDropDownChanged = d;
                n.onBirthChanged = g;
                n.onBirthBlur = nt;
                n.onAgeChanged = it;
                n.initParentSourceType = b;
                n.onMobileMouseleave = rt;
                n.addMobile = ut;
                n.editMobile = ft;
                n.deleteMobile = et;
                n.editSysitemContent = a;
                n.sensorsTrack = st;
                y();
                ot() })() } } }]);
dashboardModule.directive("revisitPlanView", ["$log", "$q", "providerSvc", "loginContext", "patientUtil", "enums", "$timeout", "$document", "dataDicSvc", "localCache", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/components/revisit-plan/revisit-plan-view.html", scope: { source: "=" }, link: function(n, c) { var a = h.getCache(h.keys.CustomerRegistrationRevisitPlan),
                l, g = function() { i.getProvidersByConsultantRole().success(t => { n.visitors = t, n.source.visitorId = t[0].id, n.source.visitorName = t[0].name, n.source.recordCreatedUser = t[0].userId }) },
                w = function() { var u = t.defer(),
                        e = n.patientPermissionLevel == f.PatientPermissionLevel.Department ? r.department || "" : "all"; return i.getDepartmentRevisitors(e).success(function(n) { u.resolve(n) }), u.promise },
                b = function() { n.visitors && n.visitors.length > 0 || (n.patientPermissionLevel == f.PatientPermissionLevel.Personal ? y([{ id: r.providerId, name: r.userName }], !1) : w().then(function(n) { y(n) })) },
                v = function() { a.saveValue(n.source.isEnabled);
                    n.source.isEnabled ? (n.source.planTime = new Date, b(), e(function() { var n = o.find("#medical-records-body");
                        n.length > 0 && n.scrollTop(n[0].scrollHeight) }, 0, !1)) : n.source.planTime = null },
                y = function(t, i) { l ? (l.setDataSource(t), l.enable(i)) : l = c.find("#visitor").kendoNameCodeFilterDropDownList({ optionLabel: "请选择执行人", dataSource: t, dataTextField: "name", dataValueField: "id", enable: i, filter: "contains", value: n.source.visitorId, change: function(i) { var u = i.sender.value() ? parseInt(i.sender.value()) : 0,
                                r = _.find(t, { id: u });
                            n.source.visitorId = r ? r.id : null;
                            n.source.visitorName = r ? r.name : null;
                            n.source.recordCreatedUser = r ? r.userId : null } }).data("kendoNameCodeFilterDropDownList") },
                p = function() { var i = t.defer(); return s.revisitTypeDic.load().then(t => { n.revisitTypes = t, i.resolve(!0) }), i.promise },
                k = function(t) { var i = t.sender.value();
                    n.source.type = i },
                d = function() { var t = u.editSysitemContent("回访类型");
                    t.result.then(() => { s.revisitTypeDic.clearCache(), p().then(() => { var t = _.any(n.revisitTypes, function(t) { return t.itemName == n.source.type });
                            t || (n.source.type = "") }) }) };
            (function() { n.onConfigSwitch = v;
                n.patientPermissionLevel = u.getPatientPermissionLevel();
                n.onRevisitTypeChanged = k;
                n.editRevisitType = d;
                p(); var t = a.loadValue();
                t && (n.source.isEnabled = JSON.parse(t));
                v() })() } } }]);
dashboardModule.directive("customerConsultEditView", ["$q", "$log", "$timeout", "enums", "aresDialog", "patientUtil", "aresNotification", "officeSvc", "loginContext", "dataDicSvc", "practiceSvc", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/dialogs/customer-consult-edit/customer-consult-edit-view.html", replace: !0, link: function(t, r) { var o = null,
                v = { consultTime: new Date },
                y = function() { r.parents(".modal-content").css("width", "450px").css("float", "right") },
                p = function(n) { t.getPatient(n).then(function() { t.onlineConsult.patientId = n;
                        nt() }) },
                l = function(i) { var u = n.defer(); return h.consultItemDic.load().then(function(n) { t.consultItems = n;
                        i ? o = r.find("#consultItems").kendoMultiSelect({ placeholder: "请选择咨询项目", dataTextField: "itemName", dataValueField: "itemName", valuePrimitive: !0, autoBind: !1, filter: "contains", dataSource: n, separator: "," }).data("kendoMultiSelect") : o.dataSource.data(n);
                        u.resolve() }), u.promise },
                at = function() { var n = t.onlineConsult && t.onlineConsult.consultItems ? t.onlineConsult.consultItems : "",
                        i = n.split(",");
                    o && (n != "" ? o.value(i) : o.value(null)) },
                w = function() { t.onlineConsult.consultItems = o.value().join(",") },
                b = function() { i(function() { l(!0) }) },
                a = function() { var i = n.defer(); return h.communicationMethodDic.load().then(function(n) { t.visitMethods = n;!t.onlineConsult.method && n && n.length > 0 && (t.onlineConsult.method = n[0].itemName);
                        i.resolve() }), i.promise },
                k = function() { t.onlineConsult = _.clone(v);
                    t.patientId && p(t.patientId);
                    b();
                    a();
                    ht() },
                d = function(n) { t.onlineConsult.method = n },
                g = function() { return t.onlineConsult ? t.onlineConsult.patientId ? t.onlineConsult.consultTime ? t.onlineConsult.method ? !t.onlineConsult.consultItems || t.onlineConsult.consultItems.length <= 0 ? "请选择咨询项目" : t.onlineConsult.content ? t.onlineConsult.content.length > 2e3 ? "咨询内容不能超过2000个字符！" : t.onlineConsult.notes && t.onlineConsult.notes.length > 200 ? "备注不能超过200个字符！" : t.needCreateNextRevisit && (!t.nextRevisitTime || !t.nextVisitorId) ? "开启回访时执行人跟回访时间不能为空！" : "" : "请输入咨询内容" : "请选择沟通方式" : "请选择回访时间" : "请选择患者" : "保存失败" },
                nt = function() { c.listPatientTags().success(function(n) { var i, u, f;
                        n = _.filter(n, function(n) { return n.isInactive == !1 });
                        i = r.find("#patientTag").data("kendoMultiSelect");
                        i ? i.dataSource.data(n) : i = r.find("#patientTag").kendoMultiSelect({ maxSelectedItems: 9, dataTextField: "itemName", dataValueField: "id", dataSource: n }).data("kendoMultiSelect");
                        u = t.patient.tags;
                        u && u.length > 0 && (f = _.pluck(u, "id"), i.value(f)) }) },
                tt = function() { var n = r.find("#patientTag").data("kendoMultiSelect"); return n ? { patientId: t.patientId, tagIds: n.value() } : null },
                it = function() { w();
                    t.nextVisitorId = r.find("#visitorList").val();
                    t.onlineConsult.consultTime = moment(t.onlineConsult.consultTime).format("YYYY-MM-DD HH:mm:ss"); var n = g();
                    n ? u.info("提示", n) : (t.onlineConsult.patientTags = tt(), t.onlineConsult.needCreateNextRevisit = t.needCreateNextRevisit, t.onlineConsult.nextRevisitTime = t.nextRevisitTime, t.onlineConsult.nextVisitorId = t.nextVisitorId, t.onlineConsult.nextVisitorName = t.nextVisitorName, t.patient && t.patient.privateTag && (t.onlineConsult.patientPrivateTag = { patientId: t.patientId, ownerId: s.userId, tagStr: t.patient.privateTag.tagStr }), t.createOrUpdateOnlineConsult(t.onlineConsult).then(function() { e.success("操作成功");
                        t.close() })) },
                rt = function() { var n = f.editSysitemContent("沟通方式");
                    n.result.then(function() { h.communicationMethodDic.clearCache();
                        a().then(function() { var n = _.any(t.visitMethods, function(n) { return n.itemName == t.onlineConsult.method });
                            n || (t.onlineConsult.method = "") }) }) },
                ut = function() { var n = f.editSysitemContent("咨询项目");
                    n.result.then(function() { h.consultItemDic.clearCache();
                        l() }) },
                ft = function() { h.systemItemDic.loadActive({ itemType: "成交意愿" }).then(function(n) { t.intentions = n }) },
                et = function() { h.systemItemDic.loadActive({ itemType: "意向说明" }).then(function(n) { t.intentionDescs = n; var i = t.onlineConsult.intentionDesc ? t.onlineConsult.intentionDesc : "请选择意向说明";
                        r.find("#intentionDescInput").data("kendoDropDownList").wrapper.attr("title", i) }) },
                ot = function(n) { var r = n.sender.value(),
                        i;
                    t.onlineConsult.intentionDesc = r;
                    i = t.onlineConsult.intentionDesc ? t.onlineConsult.intentionDesc : "请选择意向说明";
                    n.sender.wrapper.attr("title", i) },
                st = function(n) { var i = n.sender.value();
                    t.onlineConsult.intention = i },
                ht = function() { var n = s.providerId;
                    t.getVisitors(n).then(function(n) { t.visitors = n;
                        t.nextVisitorId = s.providerId; var i = _.find(t.visitors, function(n) { return n.id == t.nextVisitorId });
                        t.nextVisitorName = i.name }) },
                ct = function(n) { var i = n.sender.dataItem(n.item);
                    t.nextVisitorId = i.id;
                    t.nextVisitorName = i.name },
                lt = function() { i(function() { r.find(".slide-modal-content").find('[data-toggle="tooltip"]').tooltip() }) };
            (function() { t.needCreateNextRevisit = !1;
                t.onOnlineConsultMethodSelected = d;
                t.onVisitorSelected = ct;
                t.save = it;
                t.editOnlineConsultMethod = rt;
                t.editOnlineConsultItems = ut;
                t.onChangeConsultIntention = st;
                t.onChangeConsultIntentionDesc = ot;
                y();
                k();
                ft();
                et();
                lt() })() } } }]);
dashboardModule.controller("CustomerConsultEditCtrl", ["$log", "$filter", "$q", "$scope", "enums", "$timeout", "$modalInstance", "patientSvc", "patientUtil", "onlineConsultSvc", "host", "providerSvc", "dataDicSvc", "membershipSvc", "loginContext", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; var p = function(n) { if (n) { var t = _.filter(n, function(n) { return _.any(r.patient.patientTagUseList, function(t) { return t.tagId == n.id }) });
                r.patient.tags = t } },
        w = function(n) { var t = i.defer(); return o.getFullPatient(n).success(function(n) { if (n) { s.fillPatientPicturePromise(n);
                    r.patient = n;
                    n.privateTag && (r.tagStr = angular.copy(n.privateTag.tagStr)); var u = [a.patientTagDic.loadActive()];
                    i.all(u).then(function(n) { p(n[0]);
                        t.resolve() }) } }), t.promise },
        b = function(n) { var t = i.defer(); return o.getPatientVisitInfo(n).success(function(n) { r.visitInfo = n;
                t.resolve() }), t.promise },
        k = function(n) { r.isShowPatientDefaultData = !1; var t = i.defer(),
                u = [w(n), b(n)]; return i.all(u).then(function() { t.resolve() }), t.promise },
        d = function(n) { var t = i.defer(); return h.getOnlineConsultById(n).success(function(n) { n && _.extend(r.onlineConsult, n);
                t.resolve(!0) }), t.promise },
        g = function(n) { var t = i.defer(); return h.createOnlineConsult(n).success(function(n) { t.resolve(n) }), t.promise },
        nt = function() { e.dismiss() },
        tt = function() { e.close() },
        it = function() { var n = s.getPatientPermissionLevel();
            r.canConfig = n != u.PatientPermissionLevel.Personal },
        rt = function() { var n = i.defer(),
                t = r.patientPermissionLevel == u.PatientPermissionLevel.Department ? y.department || "" : "all"; return l.getDepartmentRevisitors(t).success(function(t) { n.resolve(t) }), n.promise };
    (function() { r.patientId = c.patientId;
        r.title = c.title;
        r.isCheckedInToday = c.isCheckedInToday;
        r.isStrongStrict = c.isStrongStrict;
        r.getPatient = k;
        r.getVisitors = rt;
        r.getOnlineConsult = d;
        r.createOrUpdateOnlineConsult = g;
        r.patientPermissionLevel = s.getPatientPermissionLevel();
        it();
        r.clean = nt;
        r.close = tt })() }]);
dashboardModule.directive("customerDetailsView", ["$log", function() { "use strict"; return { templateUrl: "/app/dashboard/views/customer-service/dialogs/customer-details/customer-details-view.html", replace: !0, link: function() {
            (function() {})() } } }]);
dashboardModule.controller("CustomerDetailsCtrl", ["$log", "$scope", "$modalInstance", "$modal", "host", "patientUtil", "aresNotification", function(n, t, i, r, u, f, e) { "use strict"; var o = function() { i.close() },
        s = function() { var n = r.open({ animation: !0, backdrop: "static", template: "<customer-revisit-edit-view><\/customer-revisit-edit-view>", controller: "CustomerRevisitEditCtrl", resolve: { host: function() { return { patientId: t.patientId } } } });
            n.result.then(function() {}) },
        h = function() { var n = r.open({ animation: !0, backdrop: "static", template: "<customer-consult-edit-view><\/customer-consult-edit-view>", controller: "CustomerConsultEditCtrl", resolve: { host: function() { return { patientId: t.patientId } } } });
            n.result.then(function() {}) },
        c = function() { window.Ares3 && i.close();
            f.createGroupFollowUpAppt(t.patientId).then(function(n) { n && e.success("预约成功") }) };
    (function() { t.cancel = o;
        t.createRevisit = s;
        t.createConsult = h;
        t.createAppt = c;
        t.tabIndex = 1;
        t.patientId = u.patientId;
        t.isHideBtn = u.isHideBtn })() }]);
dashboardModule.directive("customerRegistrationView", ["$log", "loginContext", "aresNotification", "dataDicSvc", function(n, t, i, r) { "use strict"; return { templateUrl: "/app/dashboard/views/customer-service/dialogs/customer-registration/customer-registration-view.html", replace: !0, link: function(n, u) { var b = function() { u.find(".customer-registration-body").mCustomScrollbar({ autoHideScrollbar: !0, scrollInertia: 150, theme: "light", advanced: { updateOnContentResize: !0 } }) },
                e = function(t) { for (var r, f = "", e = 0; e < n.onlineConsultCreateInfoFields.length; e++)
                        if (r = n.onlineConsultCreateInfoFields[e], r.name != "freeField" && r.name != "tags") { var o = r.text,
                                u = r.name == "patientName" ? "name" : r.name,
                                u = u == "birthDay" ? "birth" : u; if (u == "mobile" && r.isEnabled && r.isRequired) { if (n.mobileList.length == 0 || n.mobileList.length == 1 && !n.mobileList[0].mobile) { f = "请输入" + o; break } } else if (u == "phoneNumber" && r.isEnabled && r.isRequired) { if (n.phoneList.length == 0 || n.phoneList.length == 1 && !n.phoneList[0].mobile) { f = "请输入" + o; break } } else if (u == "homeAddress" && r.isEnabled && r.isRequired) { if (!t.familyAddress || _.isEmpty(t.familyAddress) || !t.familyAddress.city && !t.familyAddress.content && !t.familyAddress.district && !t.familyAddress.province) { f = "请输入家庭地址"; break } } else if (u == "privateTag" && r.isEnabled && r.isRequired) { if (!t.privateTag || _.isEmpty(t.privateTag) || !t.privateTag.tagStr) { f = "请输入我的标签"; break } } else if ((r.isEnabled && r.isRequired || r.name == "patientName") && !t[u] && t[u] != "0") { f = "请输入" + o; break } } return f ? (i.error(f), !1) : !0 },
                o = function(t) { var u = "",
                        e = _.find(n.onlineConsultCreateInfoFields, function(n) { return n.name == "freeField" }),
                        s = _.some(n.patientFreeFields, function(n) { return n.isInUse && n.isRequired }),
                        r, f, o; if (e && e.isEnabled && s && n.patientFreeFields != null && n.patientFreeFields.length > 0)
                        for (r = 0; r < n.patientFreeFields.length; r++)
                            if (f = n.patientFreeFields[r].fieldCode, o = n.patientFreeFields[r].fieldName, !t.patientFreeField[f] && !t.patientFreeField[f.toLowerCase()] && n.patientFreeFields[r].isInUse && n.patientFreeFields[r].isRequired) { u = "请输入自由项:" + o; break } return u ? (i.error(u), !1) : !0 },
                s = function() { var r = n.mobileList,
                        f, t, u; if (n.patientMobile = null, r && r.length > 0) { for (f = /^1[0-9]{10}$/, t = 0; t < r.length; t++)
                            if (u = r[t].mobile, u) { if (!f.test(u)) return i.error("请输入正确的手机号码 " + u), !1; if (r[t + 1] && r[t + 1].mobile != "" && r[t + 1].mobileType == "") return i.error("请选择号码" + (t + 1) + "的手机号码属性！"), !1; if (r[t + 1] && r[t + 1].mobile == r[t].mobile && r[t + 1].mobile != "" && r[t].mobile != "" && r[t + 1].mobileType == "本人" && r[t].mobileType == "本人") return i.error("本人手机必须唯一"), !1;
                                r[t].mobileType == "本人" && (n.patientMobile = r[t].mobile) } if (_.isBoolean(n.patient.isMobileValid) && !n.patient.isMobileValid) return i.error("患者手机号已存在"), !1 } return !0 },
                h = function() { return n.consult.consultItems ? !0 : (i.error("请选择咨询项目"), !1) },
                c = function() { if (f()) { if (!n.appt.officeId) return i.error("请选择预约机构"), !1; if (!n.appt.startTime) return i.error("请选择预约时间"), !1; if (n.appt.startTime && n.appt.startTime < new Date) return i.error("预约时间必须大于当前时间"), !1 } return !0 },
                l = function() { if (n.revisit.isEnabled) { if (!n.revisit.planTime) return i.error("请选择回访计划时间"), !1; if (!n.revisit.visitorId) return i.error("请选择回访执行人"), !1 } return !0 },
                f = function() { return n.isGroup && (n.appt.officeId || n.appt.doctorId) ? !0 : !n.isGroup && n.isApptEnabled ? !0 : !1 },
                a = function() { Ares.ensureNotDuplicated("SaveCustomerRegistration", 1e3) && e(n.patient) && o(n.patient) && s() && h() && c() && l() && n.saveData() },
                v = function() { r.officeInfoDic.load().then(function(t) { n.office = t }) },
                y = function(n, t) { var i = _.find(n, { name: t }); return i && i.isEnabled },
                p = function(n, t) { var i = _.find(n, { name: t }); return i && i.isEnabled && i.isRequired },
                w = function() { r.patientFreeFieldConfigDic.load().then(function(t) { n.patientFreeFields = _.filter(t, { isInUse: !0 }) }) };
            (function() { n.isEnabledConfigField = y;
                n.isRequiredConfigField = p;
                n.contentBodyHeight = window.innerHeight - 150 + "px";
                n.onSave = a;
                n.isNeedCreatedAppt = f;
                n.revisit = { isEnabled: !0, visitorId: t.providerId, visitorName: t.userName };
                n.patientFreeField = { targetType: 1 };
                n.patientMobile = null;
                n.mobileList = [];
                n.phoneList = [];
                n.isApptEnabled = !0;
                n.isGroup = t.isGroup;
                n.patient = { id: 0, patientType: "临时", extension: {}, customLabels: "", telephoneNumberList: [], patientFreeField: { targetType: 1 } };
                n.appt = { isPending: !0 };
                n.consult = { method: "手机" };
                v();
                w() })() } } }]);
dashboardModule.controller("CustomerRegistrationCtrl", ["$log", "$q", "$scope", "$modalInstance", "host", "patientSvc", "enums", "revisitSvc", "appointmentSvc", "onlineConsultSvc", "aresNotification", "loginContext", "freeFieldSvc", "officeOptionSvc", "officeSvc", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; var w = function() { r.close() },
        b = function() { i.patient.mobile = i.patientMobile ? i.patientMobile : i.mobileList[0].mobile;
            i.phoneList.length > 0 && (i.patient.phoneNumber = i.phoneList[0].mobile);
            i.patient.telephoneNumberList = i.mobileList.concat(i.phoneList);
            i.patient.extension.onlineConsultantId = l.providerId;
            i.patient.privateTag && i.patient.privateTag.tagStr ? i.patient.privateTag.ownerId = l.userId : i.patient.privateTag = null; var n = t.defer(),
                u = !1; if (i.patient.familyAddress)
                for (const n in i.patient.familyAddress)
                    if (i.patient.familyAddress.hasOwnProperty(n)) { const t = i.patient.familyAddress[n];
                        t && t.trim() && (u = !0) } u ? n.resolve(!0) : i.appt.officeId == i.office.id ? (i.patient.familyAddress.province = i.office.province, i.patient.familyAddress.city = i.office.city, i.patient.familyAddress.district = i.office.district, n.resolve(!0)) : y.get(i.appt.officeId).then(function(n) { n.data && (i.patient.familyAddress.province = n.data.province, i.patient.familyAddress.city = n.data.city, i.patient.familyAddress.district = n.data.district) }).finally(function() { n.resolve(!0) });
            n.promise.then(function() { f.createPatient(i.patient).success(n => { var i = [k(n.id), d(n.id), nt(n.id), g(n.id), ];
                    t.all(i).then(() => { c.success("操作成功"), r.close(!0) }) }) }) },
        k = function(n) { var r = t.defer(); return tt() ? (i.patient.patientFreeField.targetId = n, a.saveFreeField(i.patient.patientFreeField).success(function(n) { i.patient.patientFreeField = n }), r.resolve(!0)) : r.resolve(!0), r.promise },
        d = function(n) { var r = t.defer(); return i.revisit.isEnabled ? (i.revisit.patientId = n, i.revisit.state = e.RevisitState.Pending.value, i.revisit.planTime = moment(i.revisit.planTime).format("YYYY-MM-DD HH:mm:ss"), o.createOrUpdateRevisit(i.revisit).success(n => { r.resolve(n) })) : r.resolve(!0), r.promise },
        g = function(n) { var r = t.defer(); return i.isNeedCreatedAppt() ? (i.appt.patientId = n, i.appt.consultItem = i.consult.consultItems, i.appt.isFirstVisit = !0, i.appt.isPending && (i.appt.notes = "【预约时间】：" + i.appt.startTime + ";【咨询项目】：" + i.consult.consultItems + ";【成交意愿】：" + i.consult.intention + ";【咨询内容】：" + i.consult.content, i.appt.startTime && (i.appt.endTime = moment(i.appt.startTime).add(30, "m").format("YYYY-MM-DD HH:mm:ss"), i.appt.startTime = moment(i.appt.startTime).format("YYYY-MM-DD HH:mm:ss"))), s.createAppointment(i.appt).success(n => { r.resolve(n) })) : r.resolve(!0), r.promise },
        nt = function(n) { var r = t.defer(); return i.consult.channel = e.AppointmentConsultChannel.Online, i.consult.patientId = n, i.consult.consultTime = moment(new Date).format("YYYY-MM-DD HH:mm:ss"), h.createOrUpdateOnlineConsult(i.consult).success(n => { r.resolve(n) }), r.promise },
        tt = function() { for (var r, t = !1, n = 1; n <= e.FreeFieldMaxCount.Default; n++)
                if (r = "field" + n, i.patient.patientFreeField && i.patient.patientFreeField[r] !== undefined) { t = !0; break } return t },
        p = function() { var n = t.defer(),
                r = v.optionDefaultValues.OnlineConsultCreateInfoFieldsDefaultConfig,
                u = angular.copy(r); return i.onlineConsultCreateInfoFields = _.filter(u, { bigType: "患者信息" }), v.getOfficeOption(v.optionKeys.OnlineConsultCreateInfoFieldsConfig).then(function(t) { if (t) { var r = JSON.parse(t);
                    i.onlineConsultCreateInfoFields.forEach(function(n) { var t = _.find(r, { name: n.name });
                        t && (n.isEnabled = t.isEnabled, n.isRequired = t.isRequired) });
                    n.resolve(i.onlineConsultCreateInfoFields) } else n.resolve(i.onlineConsultCreateInfoFields) }), n.promise };
    (function() { i.cancel = w;
        i.saveData = b;
        i.getOnlineConsultCreateInfoFieldsConfig = p;
        p() })() }]);
dashboardModule.directive("customerRevisitEditView", ["$q", "$log", "$timeout", "enums", "aresDialog", "patientUtil", "aresNotification", "officeSvc", "loginContext", "dataDicSvc", "practiceSvc", function(n, t, i, r, u, f, e, o, s, h, c) { "use strict"; return { restrict: "E", templateUrl: "/app/dashboard/views/customer-service/dialogs/customer-revisit-edit/customer-revisit-edit-view.html", replace: !0, link: function(t, o) { var nt = function() { return { planTime: t.isRevisitTask ? new Date : null, visitTime: t.isRevisitTask ? null : new Date, visitorId: s.providerId, visitorName: s.userName, transactions: [], state: 0 } },
                tt = function() { o.parents(".modal-content").css("width", "450px").css("float", "right") },
                it = function() { t.revisit = nt();
                    t.revisitId ? t.getRevisit(t.revisitId).then(function() { t.revisit && (t.revisit.transactions && (t.selectedIds = _.pluck(t.revisit.transactions, "transactionId")), l(t.revisit.patientId), k(), w(), y());
                        a();
                        v();
                        b();
                        p() }) : (t.patientId && l(t.patientId), k(), y(), w(), a(), v(), b(), p()) },
                p = function() { t.revisit.visitTime || (t.revisit.visitTime = new Date) },
                a = function() { var i = n.defer(); return h.communicationMethodDic.load().then(function(n) { t.visitMethods = n;!t.isRevisitTask && !t.revisit.method && n && n.length > 0 && (t.revisit.method = n[0].itemName);
                        i.resolve() }), i.promise },
                w = function() { i(function() { ut() }) },
                rt = function() { c.listPatientTags().success(function(n) { var i, r, u;
                        n = _.filter(n, function(n) { return n.isInactive == !1 });
                        i = o.find("#patientTag").data("kendoMultiSelect");
                        i ? i.dataSource.data(n) : i = o.find("#patientTag").kendoMultiSelect({ maxSelectedItems: 9, dataTextField: "itemName", dataValueField: "id", dataSource: n }).data("kendoMultiSelect");
                        r = t.patient.tags;
                        r && r.length > 0 && (u = _.pluck(r, "id"), i.value(u)) }) },
                ut = function() { h.transactionCodeDic.load().then(function(n) { var r, i, u, f;
                        n && (t.transactions = n, r = o.find("#transactions"), r.kendoMultiSelect({ placeholder: "请选择回访项目", dataTextField: "name", dataValueField: "id", valuePrimitive: !0, autoBind: !1, filter: "contains", dataSource: t.transactions }), i = t.revisit.transactions, i && i.length > 0 && (u = r.data("kendoMultiSelect"), f = _.pluck(i, "transactionId"), u.value(f))) }) },
                v = function() { var i = n.defer(); return h.revisitTypeDic.load().then(function(n) { t.revisitTypes = n;!t.revisit.type && n && n.length > 0 && (t.revisit.type = n[0].itemName);
                        i.resolve() }), i.promise },
                b = function() { h.revisitStateDic.load().then(function(n) { t.revisitStates = _.filter(n, function(n) { return n.state == r.RevisitState.Completed.value || n.state == r.RevisitState.Unsuccessful.value }); var i = _.any(t.revisitStates, function(n) { return n.state == t.revisit.state });
                        i || (t.revisit.state = t.revisitStates[0].state) }) },
                k = function() { var n = s.providerId;
                    t.getVisitors(n).then(function(n) { var i, u, f;
                        t.visitors = n;
                        i = o.find("#visitorList");
                        i.kendoDropDownList({ dataTextField: "name", dataValueField: "id", optionLabel: "--请选择--", filter: "contains", dataSource: t.visitors, index: 0, select: et });
                        u = i.data("kendoDropDownList");
                        u.value(t.revisit.visitorId);
                        t.patientPermissionLevel == r.PatientPermissionLevel.Personal && u.enable(!1);
                        t.nextVisitorId = s.providerId;
                        f = _.find(t.visitors, function(n) { return n.id == t.nextVisitorId });
                        t.nextVisitorName = f.name }) },
                y = function() { h.systemItemDic.loadActive({ itemType: "跟进类型" }).then(function(n) { var r, u, i; for (t.intentions = n, r = o.find("#intentionDescInput"), r.kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", optionLabel: "--请选择--", dataSource: t.intentions, index: 0, select: d }), u = r.data("kendoDropDownList"), i = 0; i < n.length; i++) n[i].itemName == t.revisit.intentionDesc && u.select(i + 1) }) },
                ft = function() { var n = f.editSysitemContent("跟进类型", !0);
                    n.result.then(function() { y() }) },
                l = function(n) { t.getPatient(n).then(function() { t.revisit.patientId = n;
                        rt() }) },
                d = function(n) { var i = n.sender.dataItem(n.item);
                    t.revisit.intentionDesc = i.itemName },
                et = function(n) { var i = n.sender.dataItem(n.item);
                    t.revisit.visitorId = i.id;
                    t.revisit.visitorName = i.name },
                gt = function(n) { var i = n.sender.dataItem(n.item);
                    t.nextVisitorId = i.id;
                    t.nextVisitorName = i.name },
                ot = function() { var u = o.find("#transactions").data("kendoMultiSelect"),
                        n = u.value(),
                        i, r;
                    t.revisit.transactions = [];
                    n && n.length > 0 && (i = _.filter(t.transactions, function(t) { return _.contains(n, t.id) }), i && (r = [], angular.forEach(i, function(n) { r.push({ revisitId: t.revisit.id, transactionId: n.id, transactionName: n.name }) }), t.revisit.transactions = r)) },
                st = function() { var n = o.find("#patientTag").data("kendoMultiSelect"); return n ? { patientId: t.patientId, tagIds: n.value() } : null },
                ht = function(n) { t.revisit.method = n },
                ct = function(n) { t.revisit.type = n },
                g = function(n) { t.nextRevisitType = n },
                lt = function(n) { t.revisit.state = n },
                at = function() { t.isRevisitTask || ot();
                    t.nextVisitorId = o.find("#visitorListNew").val();
                    t.revisit.method = t.revisit.method && (!t.isRevisitTask || t.isEdit) ? t.revisit.method : null;
                    t.revisit.planTime = t.revisit.planTime && (t.isRevisitTask || t.isEdit) ? moment(t.revisit.planTime).format("YYYY-MM-DD HH:mm:ss") : null;
                    t.revisit.visitTime = t.revisit.visitTime && !t.isRevisitTask ? moment(t.revisit.visitTime).format("YYYY-MM-DD HH:mm:ss") : null;
                    t.isRevisitTask && (t.revisit.state = 0); var n = yt();
                    n ? u.info("提示", n) : (t.revisit.patientTags = st(), t.revisit.needCreateNextRevisit = t.needCreateNextRevisit, t.revisit.nextRevisitTime = moment(t.nextRevisitTime).format("YYYY-MM-DD HH:mm:ss"), t.revisit.nextVisitorId = t.nextVisitorId, t.revisit.nextVisitorName = t.nextVisitorName, t.revisit.nextRevisitType = t.nextRevisitType, t.revisit.nextContent = t.nextContent, t.patient && t.patient.privateTag && (t.revisit.patientPrivateTag = { patientId: t.patientId, ownerId: s.userId, tagStr: t.patient.privateTag.tagStr }), t.isBatchRevisit && (t.patientIds && t.patientIds.length > 0 || t.criteria) ? t.createRevisitList(t.revisit).then(function() { e.success("操作成功");
                        t.close() }) : t.createOrUpdateRevisit(t.revisit).then(function() { e.success("操作成功");
                        t.close() })) },
                vt = function() { return t.isBatchRevisit && (t.patientIds && t.patientIds.length > 0 || t.criteria) ? !1 : t.revisit.patientId ? !1 : !0 },
                yt = function() { if (t.revisit) { if (vt()) return "请选择患者"; if (!t.isRevisitTask && !t.revisit.method) return "请选择沟通方式"; if (!t.revisit.visitorId || t.revisit.visitorId <= 0) return "请选择执行人"; if (!t.revisit.type) return "请选择回访类型"; if (t.revisit.state < 0) return "请选择回访状态"; if (t.isRevisitTask && !t.revisit.planTime) return "请选择计划时间"; if (!t.isRevisitTask && !t.revisit.visitTime) return "请选择回访时间"; if (!t.isRevisitTask && (!t.revisit.transactions || t.revisit.transactions.length <= 0)) return "请选择回访项目"; if (!t.isRevisitTask && t.needCreateNextRevisit) { if (!t.nextRevisitTime) return "请选择下次回访时间"; if (!t.nextVisitorId || t.nextVisitorId <= 0) return "请选择执行人"; if (!t.nextRevisitType) return "请选择回访类型" } return "" } return "保存失败" },
                pt = function() { var n = f.editSysitemContent("沟通方式");
                    n.result.then(function() { h.communicationMethodDic.clearCache();
                        a().then(function() { var n = _.any(t.visitMethods, function(n) { return n.itemName == t.revisit.method });
                            n || (t.revisit.method = "") }) }) },
                wt = function() { var n = f.editSysitemContent("回访类型");
                    n.result.then(function() { h.revisitTypeDic.clearCache();
                        v().then(function() { var n = _.any(t.revisitTypes, function(n) { return n.itemName == t.revisit.type });
                            n || (t.revisit.type = "") }) }) },
                bt = function() { i(function() { o.find(".slide-modal-content").find('[data-toggle="tooltip"]').tooltip() }) },
                kt = function(n) { l(n.id) },
                dt = function() { f.createPatient(!1).then(function(n) { l(n.id) }) };
            (function() { t.selectedIds = [];
                t.needCreateNextRevisit = !1;
                t.createPatient = dt;
                t.editIntentionItems = ft;
                t.onPatientSelected = kt;
                t.onRevisitMethodSelected = ht;
                t.onIntentionDescSelected = d;
                t.onRevisitTypeSelected = ct;
                t.onNewRevisitTypeSelected = g;
                t.onNewRevisitTypeSelected = g;
                t.onRevisitStateSelected = lt;
                t.save = at;
                t.editRevisitMethod = pt;
                t.editRevisitType = wt;
                tt();
                it();
                bt() })() } } }]);
dashboardModule.controller("CustomerRevisitEditCtrl", ["$log", "$filter", "$q", "$scope", "enums", "$timeout", "$modalInstance", "loginContext", "patientSvc", "patientUtil", "revisitSvc", "host", "providerSvc", "dataDicSvc", "moduleOptionProvider", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y) { "use strict"; var p = function(n) { var t = i.defer(),
                r = [w(n), d(n)]; return i.all(r).then(function() { t.resolve() }), t.promise },
        w = function(n) { var t = i.defer(); return s.getFullPatient(n).success(function(n) { if (n) { h.fillPatientPicturePromise(n);
                    r.patient = n;
                    n.privateTag && (r.tagStr = angular.copy(n.privateTag.tagStr));
                    r.patient.privateTag || (r.patient.privateTag = {});
                    r.patient.privateTag || (r.patient.privateTag = {}); var u = [v.patientTagDic.loadActive()];
                    i.all(u).then(function(n) { k(n[0]);
                        t.resolve() }) } }), t.promise },
        b = function(n) { var t = i.defer(); return c.getRevisitById(n).success(function(n) { n && _.extend(r.revisit, n);
                t.resolve(!0) }), t.promise },
        k = function(n) { if (n) { var t = _.filter(n, function(n) { return _.any(r.patient.patientTagUseList, function(t) { return t.tagId == n.id }) });
                r.patient.tags = t } },
        d = function(n) { var t = i.defer(); return s.getPatientVisitInfo(n).success(function(n) { r.visitInfo = n;
                t.resolve() }), t.promise },
        g = function() { var n = i.defer(),
                t = r.patientPermissionLevel == u.PatientPermissionLevel.Department ? o.department || "" : "all"; return a.getDepartmentRevisitors(t).success(function(t) { n.resolve(t) }), n.promise },
        nt = function(n) { var t = i.defer(); return c.createOrUpdateRevisit(n).success(function(n) { t.resolve(n) }), t.promise },
        tt = function(n) { var t = i.defer(); return n.patientIds = r.patientIds, n.searchCriteria = r.criteria, c.createRevisitList(n).success(function(n) { t.resolve(n) }), t.promise },
        it = function() { e.dismiss() },
        rt = function() { e.close() };
    (function() { r.patientId = l.patientId;
        r.isRevisitTask = l.isRevisitTask == !0 ? !0 : !1;
        r.isEdit = l.isEdit == !0 ? !0 : !1;
        r.isDelunCustomFeatureOpen = y.isDelunCustomFeatureOpen();
        r.needSearchPatient = l.needSearchPatient;
        r.revisitId = l.revisitId;
        r.title = l.title;
        r.criteria = l.criteria;
        r.isBatchRevisit = l.isBatchRevisit;
        r.patientIds = l.patientIds;
        r.getRevisit = b;
        r.isPatientSpecified = l.patientId && l.patientId > 0;
        r.getPatient = p;
        r.getVisitors = g;
        r.createOrUpdateRevisit = nt;
        r.createRevisitList = tt;
        r.patientPermissionLevel = h.getPatientPermissionLevel();
        r.clean = it;
        r.close = rt })() }]);
dashboardModule.directive("customerServiceMedicalRecordsView", ["$log", "$window", "reportUtil", function(n, t) { "use strict"; return { templateUrl: "/app/dashboard/views/customer-service/dialogs/customer-service-medical-records/customer-service-medical-records-view.html", replace: !0, controller: "CustomerServiceMedicalRecordsCtrl", link: function(n) { var i = [],
                r = [{ key: 0, name: "咨询" }, { key: 1, name: "预约" }, { key: 2, name: "到店" }, { key: 3, name: "治疗" }, { key: 4, name: "收费" }, { key: 5, name: "离店" }, { key: 6, name: "回访" }, { key: 7, name: "完成" }],
                u = function() { var t = moment().subtract(1, "month").format("YYYY-MM-DD"),
                        i = moment().add(1, "day").format("YYYY-MM-DD");
                    n.timeSpan = { startDate: t, endDate: i };
                    n.getPatientApptRecordData(n.timeSpan) },
                f = function(t) { n.getPatientApptRecordData(t) },
                e = function() { _.each(n.apptRecord, function(n) { _.each(n.recordDetail, function(n) { if (i.length > 0) { var t = _.findIndex(i, function(t) { return t == n.detailType });
                                n.active = t > -1 ? !0 : !1 } else n.active = !0 }) }) },
                o = function(n) { var t = n.key,
                        r = _.findIndex(i, function(n) { return n == t });
                    r > -1 ? (n.active = "", i.splice(r, 1)) : (n.active = "active", i.push(t));
                    i = _.uniq(i);
                    e() };
            (function() { n.height = t.innerHeight - 310 + "px";
                n.changeRecord = o;
                n.onDateRangeChanged = f;
                n.stepArary = r;
                u() })() } } }]);
dashboardModule.controller("CustomerServiceMedicalRecordsCtrl", ["$log", "$scope", "$q", "$filter", "patientSvc", function(n, t, i, r, u) { "use strict"; var f = function(n) { var f = i.defer(),
                r = angular.copy(n),
                e; return r.endDate = moment(r.endDate).add(1, "day").format("YYYY-MM-DD"), e = { startDate: r.startDate, endDate: r.endDate, patientId: t.patientId }, u.getPatientApptRecord(e).success(function(n) { o(n);
                t.apptRecord = n;
                f.resolve(!0) }), f.promise },
        e = function(n) { var t = moment(n).format("dddd"),
                i = moment(n).format("YYYY-MM-DD"); return { week: t, date: i } },
        o = function(n) { _.each(n, function(n) { var t = e(n.recordDate);
                n.recordDate = t.date;
                n.week = t.week;
                _.each(n.recordDetail, function(n) { n.occurredTime = moment(n.occurredTime).format("HH:mm:ss");
                    n.detailJOSN = JSON.parse(n.detailJOSN);
                    n.active = !0;
                    n.detailType == 6 && (n.detailJOSN.State = r("toRevisitStateStr")(n.detailJOSN.State)) }) }) };
    (function() { t.getPatientApptRecordData = f })() }]);
dashboardModule.directive("customerServicePatientRecordsView", ["$log", "$window", function(n, t) { "use strict"; return { templateUrl: "/app/dashboard/views/customer-service/dialogs/customer-service-patient-records-view/customer-service-patient-records-view.html", replace: !0, controller: "CustomerServicePatientRecordsCtrl", link: function(n) { var i = { infoBase: [], infoFirstVisit: [], infoExamination: [], infoClientRelation: [] },
                r = { infoBase: [], infoFirstVisit: [], infoExamination: [], infoClientRelation: [] },
                u = function(n, t, u) { i[n].push(t);
                    _.isFunction(u) && r[n].push(u) };
            (function() { n.height = t.innerHeight - 250 + "px";
                n.registerOnEditingCallBackMethod = u })() } } }]);
dashboardModule.controller("CustomerServicePatientRecordsCtrl", ["$q", "$scope", "$modal", "$filter", "patientSvc", "dataDicSvc", "reportSvc", "providerSvc", "freeFieldSvc", function(n, t, i, r, u, f, e, o, s) { "use strict"; var l = function(n) { f.patientSourceTypeDic.load().then(function(i) { var r, u;
                t.patientSourceTypes = i;
                n && (r = _.find(i, function(t) { return t.sourceName == n && t.level == 2 }), r && (u = _.find(i, function(n) { return n.id == r.parentId }), t.patient.sourceTypeCategory = u.sourceName)) }) },
        a = function(n) { s.getPatientFreeFieldValue(n).success(function(i) { t.patientFreeField = i || { targetType: 1, targetId: n } }) },
        v = function(n) { e.GetPatientRelation(n).success(function(n) { for (var i = 0; i < n.length; ++i) n[i].sex = r("toSexString")(n[i].sex);
                t.isConsult = !0;
                t.patientRelation = n }) },
        y = function(n) { var i = [];
            i.push(f.doctorDic.loadActive().then(function(n) { t.doctors = n }));
            n.doctorId && i.push(o.getName(n.doctorId).then(function(n) { n && (t.patient.doctorName = n) }));
            n.dutyDoctorId && i.push(o.getName(n.dutyDoctorId).then(function(i) { i && (t.patient.dutyDoctorName = i, h(n)) })) },
        p = function(n) { var i = [];
            i.push(f.consultantDic.loadActive().then(function(n) { t.consultants = n }));
            i.push(f.webPhoneConsultantDic.loadActive().then(function(n) { t.onlineConsultants = n }));
            i.push(f.allProviderDic.loadActive().then(function(n) { t.developers = n }));
            n.consultantId && i.push(o.getName(n.consultantId).then(function(i) { t.patient.consultantName = i || "";
                h(n) }));
            n.extension.onlineConsultantId && i.push(o.getName(n.extension.onlineConsultantId).then(function(n) { t.patient.extension.onlineConsultantName = n || "" }));
            n.extension.developerId && i.push(o.getName(n.extension.developerId).then(function(n) { t.patient.extension.developerName = n || "" })) },
        w = function(n) { f.attendantDic.load().then(function(i) { if (t.attendants = i, n.attendantId) { var r = _.find(i, function(t) { return t.id == n.attendantId });
                    t.patient.attendantName = r ? r.name : "" } }) },
        h = function(n) { n.advisorId && (n.dutyDoctorId && n.dutyDoctorId == n.advisorId ? n.advisorName = t.patient.dutyDoctorName : n.consultantId && n.consultantId == n.advisorId && (n.advisorName = t.patient.consultantName)) },
        b = function() { u.getRefereeCountByPatientId(t.patientId).success(function(n) { t.refereeCount = n }) },
        k = function(n) { f.patientTagDic.loadActive().then(function(i) { return t.patientTags = angular.copy(i), u.getTagByPaitentId(n.id) }).then(function(i) { n.patientTagUseList = i.data ? i.data : []; var r = [];
                n.patientTagUseList && t.patientTags && (angular.forEach(t.patientTags, function(n) { n.textColor = n.itemValue ? Ares.getForegroundColor(n.itemValue) : Ares.getForegroundColor("#fff") }), t.patientTags.forEach(function(t) { var i = _.find(n.patientTagUseList, function(n) { return n.tagId == t.id });
                    i && (i.abbreviation = t.abbreviation, i.isHidden = t.isHidden, i.itemValue = t.itemValue, i.itemName = t.itemName, i.textColor = t.textColor, t.selected = !0, r.push(i)) }), n.patientTagUseList = r, n.patientTagUseList.forEach(function(n) {!n.abbreviation && n.itemName && (n.abbreviation = n.itemName.substring(0, 1)) })) }) },
        c = function() { var i = n.defer(); return u.getPatient(t.patientId).success(function(n) { var r, u, f;
                t.patient = n;
                n.extension || (n.extension = {});
                t.patient.birth ? (r = moment(t.patient.birth, "YYYY-MM-DD"), r.isValid() || (r = moment(t.patient.birth, "YYYYMMDD")), r.isValid() && (u = moment(Ares.today()), f = u.diff(r, "years"), t.ignoreAgeChanged = !0, t.patient.age = f)) : t.patient.age = "";
                t.patient.refereeId > 0 && (t.refereePatient = { id: t.patient.refereeId, name: t.patient.refereeName, mobile: t.patient.refereeMobileOrCode });
                t.guardianCopy = t.patient.guardian ? angular.copy(t.patient.guardian) : null;
                n.birth && (n.birth = moment(n.birth, "YYYY-MM-DD").format("YYYY-MM-DD"));
                n.firstVisit && (n.firstVisit = moment(n.firstVisit, "YYYY-MM-DD").format("YYYY-MM-DD"));
                l(n.sourceType);
                v(t.patientId);
                y(n);
                p(n);
                w(n);
                b();
                k(n);
                a(t.patientId);
                i.resolve() }), i.promise },
        d = function() { var n = i.open({ animation: !0, backdrop: "static", template: "<patient-quick-edit-view><\/patient-quick-edit-view>", controller: "PatientQuickEditCtrl", windowClass: "patient-quick-edit-dialog", size: "lg", resolve: { patientHost: function() { return { patient: angular.copy(t.patient) } } } });
            n.result.then(function() { c() }) };
    (function() { c().then(function() { u.addViewPatientDetailLog(t.patient.id, t.patient.name) });
        t.editPatient = d })() }]);
dashboardModule.directive("updateMultiCustomerPropertyView", ["$log", "$q", "$timeout", "officeSvc", "multiOfficeDataDic", "loginContext", "officeSelectorUtil", "aresNotification", "enums", "aresDialog", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; return { templateUrl: "/app/dashboard/views/customer-service/dialogs/update-multi-customer-property/update-multi-customer-property-view.html", replace: !0, link: function(n, c) { var a = function(t) { n.selectedOfficeIdsArray = _.pluck(t, "officeId");
                    l() },
                v = function() { n.providers = [{ id: 0, name: "选择转移对象" }];
                    n.jobs = [s.ProviderType.DutyDoctor, s.ProviderType.Consultant, s.ProviderType.OnlineConsultant, s.ProviderType.Attendant, s.ProviderType.Developer, ];
                    n.isGroup && r.getSelfAndChildOfficesByGroupId(f.officeId, !1).success(t => { n.officeTreeData = e.setId(t) }) },
                l = function() { var i = t.defer(),
                        r = n.isGroup && !n.fromByPatientCenter ? n.selectedOfficeIdsArray[0] : f.officeId,
                        e; return r ? (e = parseInt(n.currentSelectedJob) == s.ProviderType.Attendant.value ? "officeAttendantDic" : "currentOfficeWorkProviderDic", u.loadDic(r, e).then(function(t) { n.allProviders = angular.copy(t);
                        n.providers = y(t);
                        i.resolve(!0) })) : i.resolve(!0), i.promise },
                y = function(t) { var i = []; switch (parseInt(n.currentSelectedJob)) {
                        case s.ProviderType.DutyDoctor.value:
                            i = _.filter(t, { job: "医生" }); break;
                        case s.ProviderType.Consultant.value:
                            i = _.filter(t, { job: "咨询师" }); break;
                        case s.ProviderType.OnlineConsultant.value:
                            i = _.filter(t, { job: "网电营销" }); break;
                        default:
                            i = t } return i },
                p = function() { var t = parseInt(n.currentSelectedJob);
                    t != s.ProviderType.OnlineConsultant.value && t != s.ProviderType.Consultant.value && (n.fromByPatientCenter || t != s.ProviderType.Attendant.value) ? (n.isEnableTransferRevisit = !1, n.isTransferRevisitPlan = !1) : n.isEnableTransferRevisit = !0;
                    l().then(function() { n.providers && n.providers.length == 0 && (n.currentSelectedProvider = null) }) },
                w = function() { if (n.isGroup && !n.fromByPatientCenter && (!n.selectedOfficeIdsArray || n.selectedOfficeIdsArray.length == 0)) { o.error("请选择门店"); return } if (!n.currentSelectedJob) { o.error("请选择客户关系"); return } if (!n.currentSelectedProvider || n.currentSelectedProvider.id === 0) { o.error("选择转移对象"); return } h.confirm("提醒", "该操作将修改" + n.patientCount + "位患者客户关系，确认后将立即生效，是否继续?").then(function() { n.save() }) };
            (function() { n.onOfficeSelected = a;
                n.onJobChanged = p;
                n.selectedOfficeIdsArray = [];
                n.onSave = w;
                n.isTransferRevisitPlan = !1;
                n.isEnableTransferRevisit = !1;
                n.isTransferFollowupPlan = !1;
                n.isGroup = f.isGroup;
                v();
                i(function() { Ares.centerModal(c.closest(".modal-dialog")) }, 50) })() } } }]);
dashboardModule.controller("UpdateMultiCustomerPropertyCtrl", ["$log", "$q", "$scope", "$modalInstance", "host", "patientSvc", "aresNotification", "loginContext", function(n, t, i, r, u, f, e, o) { "use strict"; var s = function() { r.close() },
        h = function() { var n, t;
            i.fromByPatientCenter && u.criteria ? (n = { providerId: o.providerId, criteria: u.criteria.filter, isSearchPatientByDB: u.criteria.isSearchPatientByDB, transferProviderId: i.currentSelectedProvider.id, transferProviderName: i.currentSelectedProvider.name, transferProviderType: i.currentSelectedJob, isTransferRevisitPlan: i.isTransferRevisitPlan, isTransferPendingRevisitOnly: i.fromByPatientCenter && i.isTransferRevisitPlan, isTransferFollowupPlan: i.isTransferFollowupPlan }, f.batchEditPatientRelationshipAsync(n).success(function() { e.success("您的批量操作处理需要一定时间，请稍后查看处理结果");
                r.close(!0) })) : (t = { patientIds: u.patientIds, providerId: i.currentSelectedProvider.id, providerName: i.currentSelectedProvider.name, providerType: i.currentSelectedJob, isTransferRevisitPlan: i.isTransferRevisitPlan, searchCriteria: u.criteria, isTransferPendingRevisitOnly: i.fromByPatientCenter && i.isTransferRevisitPlan, isTransferFollowupPlan: i.isTransferFollowupPlan }, f.batchUpdatePatientRelationship(t).success(() => { e.success("操作成功"), r.close(!0) })) };
    (function() { i.cancel = s;
        i.save = h;
        i.patientCount = u.patientCount;
        i.fromByPatientCenter = u.fromByPatientCenter })() }]);
dashboardModule.directive("groupDashboardApptWorkBlock", ["$log", "$timeout", "$q", "$window", "$modal", "$filter", "apptUtil", "appNav", "officeOptionSvc", "aresNotification", "loginContext", "localCache", "sessionCache", "gridOptionUtil", "dataDicSvc", "aresDialog", "dashboardSvc", "practiceSvc", "patientUtil", "enums", "eventAggregator", "permissionProvider", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b, k, d, g, nt) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/group/group-dashboard-appt-work-block.html", controller: "GroupDashboardApptWorkCtrl", scope: { titleClass: "@" }, link: function(n, e) { var rt = Ares.kendoGridUtil(r, n),
                h = null,
                ci = a.getCache(a.keys.PageSize),
                tt = l.getCache(l.keys.GroupDashboardApptWorkFields),
                s = tt.loadObject();
            s = _.isArray(s) ? s : []; var g = null,
                ut, it = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientName", title: "患者姓名", width: "120px", isHidden: !1, code: "patientName", index: 30, attributes: { "class": "patient-td" }, template: function() { return '<ares-patient-namecard patient="::dataItem.patientHead" appt="::dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' } }, { field: "sexStr", title: "性别", width: "80px", isHidden: !1, code: "sexStr", index: 40 }, { field: "ageStr", title: "年龄", width: "80px", isHidden: !1, code: "ageStr", index: 50 }, { field: "mobile", title: "手机", width: "120px", isHidden: !1, code: "mobile", index: 60 }, { field: "privateId", title: "病历号", width: "150px", isHidden: !0, code: "privateId", index: 70 }, { field: "sourceType1", title: "来源一级", width: "120px", isHidden: !0, code: "sourceType1", index: 80 }, { field: "sourceType2", title: "来源二级", width: "120px", isHidden: !0, code: "sourceType2", index: 90 }, { field: "sourceType3", title: "来源三级", width: "120px", isHidden: !0, code: "sourceType3", index: 100 }, { field: "consultantNameStr", title: "网电咨询师", width: "130px", isHidden: !1, code: "consultantNameStr", index: 101 }, { field: "createdUser", title: "创建人", width: "120px", isHidden: !1, code: "createdUser", index: 110 }, { field: "recordCreatedTimeStr", title: "创建时间", width: "180px", isHidden: !1, code: "recordCreatedTimeStr", index: 120 }, { field: "firstVisitStr", title: "初诊日期", width: "120px", isHiddern: !0, code: "firstVisitStr", index: 125 }, { field: "officeName", title: "预约门店", width: "120px", isHidden: !0, code: "officeName", index: 130 }, { field: "startTimeStr", title: "预约时间", width: "120px", isHidden: !1, code: "startTimeStr", index: 150 }, { field: "checkInType", title: "就诊类型", width: "120px", isHidden: !0, code: "checkInType", index: 155 }, { field: "checkInTimeStr", title: "就诊时间", width: "120px", isHidden: !1, code: "checkInTimeStr", index: 160 }, { field: "doctorName", title: "医生", width: "120px", isHidden: !1, code: "doctorName", index: 170 }, { field: "transactionItems", title: "预约项目", width: "120px", isHidden: !1, code: "transactionItems", index: 180 }, { field: "consultantName", title: "咨询师", width: "120px", isHidden: !1, code: "consultantName", index: 190 }, { field: "actualPrice", title: "消费金额(实收)", width: "160px", format: "{0:n}", isHidden: !1, code: "actualPrice", index: 200 }, { field: "performance", title: "绩效收入", width: "160px", format: "{0:n}", isHidden: !0, code: "performance", index: 200 }, { field: "superType", title: "收费大类", width: "120px", isHidden: !0, code: "superType", index: 210 }, { field: "itemType", title: "收费小类", width: "120px", isHidden: !0, code: "itemType", index: 220 }, { field: "notes", title: "备注", width: "120px", isHidden: !1, code: "notes", index: 230 }, ]; var p = null,
                ft = function() { var r = this,
                        u = r.element,
                        t = u.find(".k-grid-header"),
                        f = t.find(".k-header-column-menu:gt(0)").length,
                        i;
                    f > 0 && (t.find(".k-header-column-menu:gt(0)").remove(), t.find(".k-header:gt(0)").each(function(n, t) { var i = $(t).find("a");
                        i.css("margin-right", "0") }));
                    $(e).find("#groupApptWorkList table tbody tr").each(function(t, i) { var u = r.dataItem(i),
                            f, t;
                        u.isCheckedIn || e.find(i).find("td .cell-command").remove();
                        (u.isCheckedIn || u.isConfirmed || !nt.isEditAllApptAllowed && u.createdUserId != c.userId) && e.find(i).find("td .edit-command").attr("disabled", !0);
                        f = e.find("#groupApptWorkList").data("kendoGrid");
                        t = $(this).index() + 1 + n.pageSize * (n.pageIndex - 1);
                        e.find(i).find("td .row-number").html(t) });
                    i = u.find("button");
                    i.data({ toggle: "tooltip", placement: "top", container: "body", trigger: "hover" });
                    i.tooltip() },
                et = function(t) { n.showColumns = t },
                b = function(n, i) { g && t.cancel(g);
                    g = t(function() { if (i) { var t = _.find(s, { code: n.column.code });
                            t && (t.width = n.newWidth + "px", tt.saveObject(s)) } else v.updateColumnsOption(v.keys.groupDashboardApptWorkGridOption, n.sender.columns, et) }, 1500) },
                ot = function(t) { var i = n.showColumns; return _.isArray(n.showColumns) || (i = n.showColumns.split(",")), i = _.filter(i, function(n) { return n && n.indexOf("undefined") == -1 }), v.formatColumns(t, i, s), t = _.sortBy(t, "index"), angular.forEach(t, function(n) { s.push({ code: n.code, width: n.width }) }), t },
                o = function() { n.refreshApptWork().then(function(t) { var i, f, u;
                        n.updateCount();
                        p = angular.copy(it);
                        p = ot(p);
                        t.items || (t.items = []);
                        i = e.find("#groupApptWorkList");
                        h = i.data("kendoGrid");
                        h ? h.dataSource.data(t.items) : (f = i.offset().top, u = r.innerHeight - (250 + e.find("#divCondition").height()), p.push({ template: rt.commandTemplate, title: "操作", width: "200px", index: 300 }), n.apptGridOption = { excel: { allPages: !0 }, dataSource: { data: t.items }, height: u, model: { id: "id" }, columns: p, dataBound: ft, sortable: !0, resizable: !0, reorderable: !0, columnMenu: !0, columnShow: function(n) { b(n) }, columnHide: function(n) { b(n) }, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                t.find("li").each(function(n, t) { var i = $(t).text();
                                    i == " " && $(t).remove() }) }, columnReorder: function(n) { b(n) }, columnResize: function(n) { b(n, !0) } }) }) },
                st = function(t, i) { i = i || "d"; var r = moment(n.date).add(t, i).toDate();
                    n.date = r;
                    o() },
                ht = function(t) { n.selectStatus = t;
                    o() },
                ct = function() { o() },
                lt = [{ text: "编辑", action: "update", icon: "iconfont icon-bianji", className: "edit-command" }, { text: "新建回访任务", action: "revisitTask", icon: "iconfont icon-xinjianhuifangrenwu", "class": "new-revisit-task-command" }, { text: "新建回访", action: "revisit", icon: "iconfont icon-xinjianhuifang", "class": "new-revisit-command" }, { text: "查看处置", action: "load", icon: "iconfont icon-yiliaomedical14", className: "cell-command" }, ],
                at = function(t) { return _.find(n.pageData.items, function(n) { return t == n.id }) },
                vt = function(t) { return _.find(n.pageData.items, function(n) { return n.id == t }) },
                yt = function(t, i, r) { var f = at(r),
                        u = vt(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                n.editAppt(r); break;
                            case "revisitTask":
                                n.showRevisitTask(u); break;
                            case "revisit":
                                n.showRevisit(u); break;
                            case "load":
                                n.showDiagnoseRecord(f) } }) },
                pt = function() { n.initSearchCriteria().then(function(n) { h || (h = e.find("#groupApptWorkList").data("kendoGrid")); var t = { criteria: n, columns: h.columns };
                        w.exportGroupApptWork(t) }) },
                wt = function() { var t = e.find("#daySelectBtn");
                    t.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 });
                    t.datepicker("setDate", moment(n.date).format(n.dateFormat));
                    t.on("changeDate", function(t) { $("#daySelectBtn").datepicker("hide");
                        n.date = t.date;
                        o() }) },
                bt = function(t) { n.pageIndex = t;
                    o() },
                kt = function(t) { n.pageSize = t;
                    o() },
                dt = function() { var n = $(window).height(),
                        t = 250 + e.find("#divCondition").height(),
                        i = n - t,
                        r = i - 81; return Math.max(5, parseInt(r / 40)) },
                gt = function() { var t = angular.copy(n.selectedIdsStr),
                        i = angular.copy(n.selectedNamesMulti),
                        r = u.open({ animation: !0, backdrop: "static", template: "<office-group-dialog-view><\/office-group-dialog-view>", controller: "OfficeGroupDialogCtrl", windowClass: "office-group-dialog", resolve: { host: function() { return { selectMode: "multi", selectScope: "office", selectedIds: t, selectedNames: i } } } });
                    r.result.then(function(t) { if (t && t.selectedIds) { n.selectedNamesMulti = t.selectedNames;
                            n.selectedIdsStr = t.selectedIds; var i = t.selectedIds.split(","),
                                r = 0;
                            i && (r = i.length);
                            r == 1 ? (n.isShowTransactionItem = !0, n.selectedOfficeId = i[0]) : (n.isShowTransactionItem = !1, n.selectedOfficeId = null) } else n.selectedNamesMulti = "", n.selectedIdsStr = "", n.isShowTransactionItem = !1, n.selectedOfficeId = null;
                        o() }) },
                ni = function(t) { var i = this.dataItem(t.item.index());
                    n.selectedUserId = i.id;
                    o() },
                ti = function() { var t = i.defer(),
                        r, u; return n.isPersonalLevel ? (u = [{ id: c.providerId, name: f("toTenantNetworkConsultantName")(c.providerId) }], t.resolve(u)) : (r = n.isAllLevel ? "all" : c.department ? c.department : "", n.getConsultants(r).then(function(n) { t.resolve(n) })), t.promise },
                ii = function() { var t = i.defer(); return ti().then(function(i) { n.groupCreatedUsers = angular.copy(i);
                        i.splice(0, 0, { id: "", name: "全部" });
                        i.push({ id: "-1", name: "其他" });
                        e.find("#groupOnlineConsultantInput").kendoDropDownList({ dataTextField: "name", dataValueField: "id", dataSource: i, index: 0, select: ni });
                        t.resolve() }), t.promise },
                ri = function() { var t, i, r; return n.isExcludeUsers = !1, t = "", i = n.selectedUserId, i !== "-1" ? t = i : (n.isExcludeUsers = !0, n.groupCreatedUsers && n.groupCreatedUsers.length > 0 && (r = _.pluck(n.groupCreatedUsers, "id"), t = r.join(","))), t },
                ui = function() { var t = this.value();
                    n.selectedConsultId = t.join(",");
                    o() },
                fi = function() { var t = i.defer(),
                        r; return n.isPersonalLevel ? t.resolve() : (r = n.isAllLevel ? "all" : c.department ? c.department : "", n.getConsultants(r).then(function(i) { n.groupConsultants = angular.copy(i);
                        ut = e.find("#groupNetworkConsultantInput").kendoMultiSelect({ dataTextField: "name", dataValueField: "id", dataSource: i, change: ui }).data("kendoMultiSelect");
                        t.resolve() })), t.promise },
                ei = function() { var t = c.providerId,
                        i, r; return n.isPersonalLevel || (i = n.selectedConsultId, i === "" || _.isUndefined(i) ? n.isAllLevel ? t = "" : n.groupConsultants && n.groupConsultants.length > 0 && (r = _.pluck(n.groupConsultants, "id"), t = r.join(",")) : t = i), t },
                oi = function() { var t = [n.loadColumnsOption(), fi(), ii()]; return i.all(t) },
                si = function() { var t = k.getPatientPermissionLevel();
                    n.isDepartmentLevel = t == d.PatientPermissionLevel.All || t == d.PatientPermissionLevel.Department;
                    n.isPersonalLevel = t == d.PatientPermissionLevel.Personal;
                    n.isAllLevel = t == d.PatientPermissionLevel.All;
                    c.isGroup ? (n.selectedOfficeId = null, n.isShowTransactionItem = !1) : (n.selectedOfficeId = c.officeId, n.isShowTransactionItem = !0);
                    n.selectedIdsStr = "";
                    n.selectedConsultId = "";
                    y.networkConsultantTenantDic.load().then(function() { oi().then(function() { o() }) }) },
                hi = function() { y.systemsettingSmartDic.load().then(function(t) { var i = _.filter(t, function(n) { return n.itemType == "就诊类型" }),
                            r;
                        i.unshift({ itemName: "全部" });
                        r = e.find("#checkInTypeInput");
                        r.kendoDropDownList({ dataSource: i, dataTextField: "itemName", dataValueField: "itemName", value: n.apptCheckInType || null, select: function(t) { n.apptCheckInType = this.dataItem(t.item)[this.options.dataValueField] || null;
                                n.apptCheckInType && n.apptCheckInType == "全部" && (n.apptCheckInType = null);
                                o() } }) }) };
            (function() { n.maxPageCount = 10;
                n.isInitialize = !0;
                n.selectStatus = "all";
                n.selectedNamesMulti = null;
                n.selectedIdsStr = null;
                n.isGroup = c.isGroup;
                n.officeId = n.isGroup ? 0 : c.officeId;
                n.selectCode = "";
                n.date = Ares.today();
                n.pageIndex = 1;
                n.pageSize = dt();
                n.onPageChanged = bt;
                n.onPageSizeChanged = kt;
                n.navigate = st;
                n.switchStatus = ht;
                n.toggleStateSelection = ct;
                n.commands = lt;
                n.onCommandClick = yt;
                n.exportExcel = pt;
                n.refreshGrid = o;
                n.openOfficeGroupTestMultDialog = gt;
                n.getConsultantIds = ei;
                n.getUserIds = ri;
                hi();
                wt();
                si() })() } } }]);
dashboardModule.directive("groupDashboardFrontView", ["$log", "$timeout", "$state", "appNav", "enums", "dashboardSvc", "patientSvc", "moduleOptionProvider", "aresDialog", "practiceSvc", "loginContext", function(n, t, i, r, u, f, e, o) { return { restrict: "E", templateUrl: "/app/dashboard/views/group/group-dashboard-front-view.html", scope: { officeId: "=", groupType: "&" }, controller: "GroupDashboardFrontCtrl", link: function(n) { var t = function(t) { n.currentState = t;
                    r.switchState(t, {}) },
                u = function() { n.groupType({ type: "new" }) },
                f = function() { var r = n.listBlocks[0].stateName;
                    i.current.name && i.current.name != "dashBoard" && (r = i.current.name);
                    i.params.status && (r = i.params.status);
                    _.all(n.listBlocks, function(n) { return n.stateName != r }) && (r = n.listBlocks[0].stateName);
                    t(r);
                    o.isNewOnlineConsultantEnabled() && (n.isShowNewOnline = !0) };
            (function() { n.switchState = t;
                n.listContentHeight = $(window).height() - 150 + "px";
                n.backNewGroup = u;
                f();
                n.$on("to-parent-current-state", function(t, i) { n.currentState = i }) })() } } }]);
dashboardModule.directive("groupDashboardOnlineConsultView", ["$log", "$timeout", "$q", "$window", "apptUtil", "appNav", "officeOptionSvc", "aresNotification", "loginContext", "localCache", "sessionCache", "gridOptionUtil", "dataDicSvc", "aresDialog", "dashboardSvc", "practiceSvc", "patientUtil", "enums", "eventAggregator", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/group/group-dashboard-online-consult-view.html", controller: "GroupDashboardOnlineConsultCtrl", scope: { titleClass: "@" }, link: function(n, i) { var g = Ares.kendoGridUtil(r, n),
                o = null,
                pt = c.getCache(c.keys.PageSize),
                k = h.getCache(h.keys.GroupDashboardOnlineConsultFields),
                f = k.loadObject();
            f = _.isArray(f) ? f : []; var p = null,
                d = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientName", title: "姓名", width: "120px", isHidden: !1, code: "patientName", index: 30, template: '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem.lastAppt" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' }, { field: "sexStr", title: "性别", width: "80px", isHidden: !1, code: "sexStr", index: 40 }, { field: "ageStr", title: "年龄", width: "80px", isHidden: !1, code: "ageStr", index: 50 }, { field: "mobile", title: "手机", width: "120px", isHidden: !1, code: "mobile", index: 60 }, { field: "privateId", title: "病历号", width: "150px", isHidden: !0, code: "privateId", index: 70 }, { field: "sourceType1", title: "来源一级", width: "120px", isHidden: !0, code: "sourceType1", index: 80 }, { field: "sourceType2", title: "来源二级", width: "120px", isHidden: !0, code: "sourceType2", index: 90 }, { field: "sourceType3", title: "来源三级", width: "120px", isHidden: !0, code: "sourceType3", index: 100 }, { field: "createdUser", title: "创建人", width: "120px", isHidden: !1, code: "createdUser", index: 110 }, { field: "consultTimeStr", title: "咨询时间", width: "180px", isHidden: !1, code: "consultTimeStr", index: 120 }, { field: "consultItems", title: "咨询项目", width: "120px", isHidden: !1, code: "consultItems", index: 130 }, { field: "content", title: "咨询内容", width: "120px", isHidden: !1, code: "content", index: 140 }, { field: "method", title: "沟通方式", width: "120px", isHidden: !0, code: "method", index: 150 }, { field: "notes", title: "备注", width: "120px", isHidden: !1, code: "notes", index: 160 }, ]; var e = null,
                nt = function() { var u = this,
                        f = u.element,
                        t = f.find(".k-grid-header"),
                        e = t.find(".k-header-column-menu:gt(0)").length,
                        r;
                    e > 0 && (t.find(".k-header-column-menu:gt(0)").remove(), t.find(".k-header:gt(0)").each(function(n, t) { var i = $(t).find("a");
                        i.css("margin-right", "0") }));
                    $(i).find("#groupOnlineConsultList table tbody tr").each(function(t, r) { var f = u.dataItem(r),
                            e = i.find("#groupOnlineConsultList").data("kendoGrid"),
                            t = $(this).index() + 1 + n.pageSize * (n.pageIndex - 1);
                        i.find(r).find("td .row-number").html(t) });
                    r = f.find("button");
                    r.data({ toggle: "tooltip", placement: "top", container: "body", trigger: "hover" });
                    r.tooltip() },
                tt = function(t) { n.showColumns = t },
                v = function(n, i) { p && t.cancel(p);
                    p = t(function() { if (i) { var t = _.find(f, { code: n.column.code });
                            t && (t.width = n.newWidth + "px", k.saveObject(f)) } else l.updateColumnsOption(l.keys.groupDashboardOnlineConsultGridOption, n.sender.columns, tt) }, 1500) },
                it = function(t) { var i = n.showColumns; return _.isArray(n.showColumns) || (i = n.showColumns.split(",")), i = _.filter(i, function(n) { return n && n.indexOf("undefined") == -1 }), l.formatColumns(t, i, f), t = _.sortBy(t, "index"), angular.forEach(t, function(n) { f.push({ code: n.code, width: n.width }) }), t },
                u = function() { n.refreshOnlineConsult().then(function(t) { if (n.updateCount(), e = angular.copy(d), e = it(e), o) t.items || (t.items = []), o.dataSource.data(t.items);
                        else { var u = i.find("#groupOnlineConsultList"),
                                s = u.offset().top,
                                f = r.innerHeight - 290;
                            e.push({ template: g.commandTemplate, title: "操作", width: "160px", index: 200 });
                            n.onlineConsultGridOption = { excel: { allPages: !0 }, dataSource: { data: t.items }, height: f, model: { id: "id" }, columns: e, dataBound: nt, sortable: !0, resizable: !0, reorderable: !0, columnMenu: !0, columnShow: function(n) { v(n) }, columnHide: function(n) { v(n) }, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                    n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                    t.find("li").each(function(n, t) { var i = $(t).text();
                                        i == " " && $(t).remove() }) }, columnReorder: function(n) { v(n) }, columnResize: function(n) { v(n, !0) } };
                            o = i.find("#groupOnlineConsultList").data("kendoGrid") } }) },
                rt = function(t, i) { i = i || "d"; var r = moment(n.date).add(t, i).toDate();
                    n.date = r;
                    u() },
                ut = function() { u() },
                ft = [{ text: "修改咨询记录", action: "update", icon: "iconfont icon-bianji", className: "edit-command " }, { text: "删除咨询记录", action: "delete", icon: "iconfont icon-shanchu", className: "cell-command" }, ],
                et = function(t) { return _.find(n.pageData.items, function(n) { return n.id == t }) },
                ot = function(t, i, r) { var u = et(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                n.editConsult(u); break;
                            case "delete":
                                n.deleteOnlineConsult(u.onlineConsultId) } }) },
                st = function() { n.initSearchCriteria().then(function(n) { var t = { criteria: n, columns: o.columns };
                        y.exportGroupOnlineConsult(t) }) },
                ht = function() { a.groupConsultantDic.loadActive().then(function(t) { var r = w.getPatientPermissionLevel(),
                            f;
                        r == b.PatientPermissionLevel.Department ? t = _.filter(t, function(n) { return n.department == s.department }) : r == b.PatientPermissionLevel.Personal && (t = _.filter(t, function(n) { return n.id == s.providerId }));
                        f = i.find("#groupOnlineConsultantInput").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "userID", select: function(t) { n.userId = this.dataItem(t.item)[this.options.dataValueField] || -1;
                                u() } }) }) },
                ct = function() { var r = i.find("#daySelectBtn");
                    r.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectBtn").datepicker("hide");
                        n.isInitialize ? n.isInitialize = !1 : t(function() { n.date = i.date;
                            u() }, 100) });
                    r.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                lt = function() { var n = $(window).height(),
                        t = n - 240,
                        i = t - 81; return Math.max(5, parseInt(i / 40)) },
                at = function(t) { n.pageIndex = t;
                    u() },
                vt = function(t) { n.pageSize = t;
                    u() },
                yt = function() { n.loadColumnsOption().then(function() { u() }) };
            (function() { n.isGroup = s.isGroup;
                n.officeId = n.isGroup ? 0 : s.officeId;
                n.selectCode = "";
                n.date = Ares.today();
                n.pageIndex = 1;
                n.pageSize = lt();
                n.navigate = rt;
                n.onPageChanged = at;
                n.onPageSizeChanged = vt;
                n.toggleStateSelection = ut;
                n.isDepartmentLevel = w.getPatientPermissionLevel() == b.PatientPermissionLevel.All || w.getPatientPermissionLevel() == b.PatientPermissionLevel.Department;
                n.commands = ft;
                n.onCommandClick = ot;
                n.exportExcel = st;
                n.refreshGrid = u;
                yt();
                ct();
                t(function() { ht() }) })() } } }]);
dashboardModule.directive("groupDashboardRevisitView", ["$log", "$timeout", "$q", "$window", "apptUtil", "appNav", "officeOptionSvc", "aresNotification", "loginContext", "localCache", "sessionCache", "gridOptionUtil", "dataDicSvc", "aresDialog", "dashboardSvc", "practiceSvc", "patientUtil", "enums", "eventAggregator", function(n, t, i, r, u, f, e, o, s, h, c, l, a, v, y, p, w, b) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/group/group-dashboard-revisit-view.html", controller: "GroupDashboardRevisitCtrl", scope: { titleClass: "@" }, link: function(n, i) { var g = Ares.kendoGridUtil(r, n),
                o = null,
                wt = c.getCache(c.keys.PageSize),
                k = h.getCache(h.keys.GroupDashboardRevisitFields),
                f = k.loadObject();
            f = _.isArray(f) ? f : []; var p = null,
                d = [{ field: "rowNumber", title: " ", sortable: !1, index: 0, code: "index", width: "32px", template: "<span class='row-number'><\/span>", attributes: { style: "padding: 0" } }, { field: "patientName", title: "姓名", width: "120px", isHidden: !1, code: "patientName", index: 30, template: '<ares-patient-namecard patient="dataItem.patientHead" appt="dataItem" mode="mini" nav-enabled="true"><\/ares-patient-namecard>' }, { field: "sexStr", title: "性别", width: "80px", isHidden: !1, code: "sexStr", index: 40 }, { field: "ageStr", title: "年龄", width: "80px", isHidden: !1, code: "ageStr", index: 50 }, { field: "mobile", title: "手机", width: "120px", isHidden: !1, code: "mobile", index: 60 }, { field: "privateId", title: "病历号", width: "150px", isHidden: !0, code: "privateId", index: 70 }, { field: "sourceType1", title: "来源一级", width: "120px", isHidden: !0, code: "sourceType1", index: 80 }, { field: "sourceType2", title: "来源二级", width: "120px", isHidden: !0, code: "sourceType2", index: 90 }, { field: "sourceType3", title: "来源三级", width: "120px", isHidden: !0, code: "sourceType3", index: 100 }, { field: "planTimeStr", title: "计划时间", width: "120px", isHidden: !1, code: "planTimeStr", index: 110 }, { field: "visitTimeStr", title: "回访时间", width: "180px", isHidden: !1, code: "visitTimeStr", index: 120 }, { field: "visitorName", title: "回访人", width: "120px", isHidden: !1, code: "visitorName", index: 130 }, { field: "type", title: "回访类型", width: "120px", isHidden: !1, code: "type", index: 140 }, { field: "transactionItems", title: "回访项目", width: "120px", isHidden: !1, code: "transactionItems", index: 150 }, { field: "content", title: "回访内容", width: "120px", isHidden: !1, code: "content", index: 160 }, { field: "stateStr", title: "回访状态", width: "120px", isHidden: !1, code: "stateStr", index: 170 }, { field: "notes", title: "备注", width: "120px", isHidden: !1, code: "notes", index: 180 }, ]; var nt = function() { var u = this,
                        f = u.element,
                        t = f.find(".k-grid-header"),
                        e = t.find(".k-header-column-menu:gt(0)").length,
                        r;
                    e > 0 && (t.find(".k-header-column-menu:gt(0)").remove(), t.find(".k-header:gt(0)").each(function(n, t) { var i = $(t).find("a");
                        i.css("margin-right", "0") }));
                    $(i).find("#groupRevisitList table tbody tr").each(function(t, r) { var f = u.dataItem(r),
                            e, t;
                        f.state == 0 ? f.visitorId == s.providerId && f.recordCreatedUser != s.userId ? i.find(r).find("td .edit-command").remove() : f.visitorId != s.providerId && f.recordCreatedUser == s.userId && i.find(r).find("td .execute-command").remove() : i.find(r).find("td .execute-command").remove();
                        e = i.find("#groupRevisitList").data("kendoGrid");
                        t = $(this).index() + 1 + n.pageSize * (n.pageIndex - 1);
                        i.find(r).find("td .row-number").html(t) });
                    r = f.find("button");
                    r.data({ toggle: "tooltip", placement: "top", container: "body", trigger: "hover" });
                    r.tooltip() },
                e = null,
                tt = function(t) { n.showColumns = t },
                v = function(n, i) { p && t.cancel(p);
                    p = t(function() { if (i) { var t = _.find(f, { code: n.column.code });
                            t && (t.width = n.newWidth + "px", k.saveObject(f)) } else l.updateColumnsOption(l.keys.groupDashboardRevisitGridOption, n.sender.columns, tt) }, 1500) },
                it = function(t) { var i = n.showColumns; return _.isArray(n.showColumns) || (i = n.showColumns.split(",")), i = _.filter(i, function(n) { return n && n.indexOf("undefined") == -1 }), l.formatColumns(t, i, f), t = _.sortBy(t, "index"), angular.forEach(t, function(n) { f.push({ code: n.code, width: n.width }) }), t },
                u = function() { n.refreshRevisit().then(function(t) { if (n.updateCount(), e = angular.copy(d), e = it(e), o) t.items || (t.items = []), o.dataSource.data(t.items);
                        else { var u = i.find("#groupRevisitList"),
                                s = u.offset().top,
                                f = r.innerHeight - 290;
                            e.push({ template: g.commandTemplate, title: "操作", width: "160px", index: 200 });
                            n.revisitGridOption = { excel: { allPages: !0 }, dataSource: { data: t.items }, height: f, model: { id: "id" }, columns: e, dataBound: nt, sortable: !0, resizable: !0, reorderable: !0, columnMenu: !0, columnShow: function(n) { v(n) }, columnHide: function(n) { v(n) }, columnMenuInit: function(n) { n.container.find(".k-sort-asc").remove();
                                    n.container.find(".k-sort-desc").remove(); var t = $(n.container).find(".k-menu-group");
                                    t.find("li").each(function(n, t) { var i = $(t).text();
                                        i == " " && $(t).remove() }) }, columnReorder: function(n) { v(n) }, columnResize: function(n) { v(n, !0) } };
                            o = i.find("#groupRevisitList").data("kendoGrid") } }) },
                rt = function(t, i) { i = i || "d"; var r = moment(n.date).add(t, i).toDate();
                    n.date = r;
                    u() },
                ut = function() { var r = i.find("#revisitState").kendoDropDownList({ dataSource: [{ name: "全部", value: -1 }, { name: "待计划", value: 0 }, { name: "已完成", value: 1 }, { name: "未成功", value: 2 }, { name: "已取消", value: 3 }, ], dataTextField: "name", dataValueField: "value", template: "#: name # ", valueTemplate: "#: name #", select: function(i) { var r = this;
                            t(function() { var t = r.dataItem(i.item)[r.options.dataValueField];
                                n.revisitState = _.isUndefined(t) ? -1 : t;
                                u() }) } }).data("kendoDropDownList") },
                ft = function() { u() },
                et = [{ text: "编辑", action: "update", icon: "iconfont icon-bianji", className: "edit-command" }, { text: "执行", action: "execute", icon: "iconfont icon-zhihang", className: "execute-command" }, { text: "删除", action: "delete", icon: "iconfont icon-shanchu", className: "delete-command" }, ],
                ot = function(t) { return _.find(n.pageData.items, function(n) { return n.id == t }) },
                st = function(t, i, r) { var u = ot(r);
                    n.$apply(function() { switch (i) {
                            case "update":
                                n.editRevisit(u); break;
                            case "execute":
                                n.executeRevisit(u); break;
                            case "delete":
                                n.deleteRevisit(u.revisitId) } }) },
                ht = function() { n.initSearchCriteria().then(function(n) { var t = { criteria: n, columns: o.columns };
                        y.exportGroupRevisit(t) }) },
                ct = function() { a.revisitorDic.loadActive().then(function(t) { var r = w.getPatientPermissionLevel(),
                            f;
                        r == b.PatientPermissionLevel.Department ? t = _.filter(t, function(n) { return n.department == s.department }) : r == b.PatientPermissionLevel.Personal && (t = _.filter(t, function(n) { return n.id == s.providerId }));
                        f = i.find("#groupOnlineConsultantInput").kendoDropDownList({ dataSource: t, optionLabel: "全部", dataTextField: "name", dataValueField: "id", filter: "contains", select: function(t) { n.userId = this.dataItem(t.item)[this.options.dataValueField] || -1;
                                u() } }) }) },
                lt = function() { var r = i.find("#daySelectBtn");
                    r.datepicker({ orientation: "top auto", language: "zh-CN", todayHighlight: !0 }).on("changeDate", function(i) { $("#daySelectBtn").datepicker("hide");
                        n.isInitialize ? n.isInitialize = !1 : t(function() { n.date = i.date;
                            u() }, 100) });
                    r.datepicker("setDate", moment(n.date).format(n.dateFormat)) },
                at = function() { var n = $(window).height(),
                        t = n - 240,
                        i = t - 81; return Math.max(5, parseInt(i / 40)) },
                vt = function(t) { n.pageIndex = t;
                    u() },
                yt = function(t) { n.pageSize = t;
                    u() },
                pt = function() { n.loadColumnsOption().then(function() { u() }) };
            (function() { n.isGroup = s.isGroup;
                n.officeId = n.isGroup ? 0 : s.officeId;
                n.revisitState = -1;
                n.selectCode = "";
                n.date = Ares.today();
                n.pageIndex = 1;
                n.pageSize = at();
                n.navigate = rt;
                n.onPageChanged = vt;
                n.onPageSizeChanged = yt;
                n.toggleStateSelection = ft;
                n.isDepartmentLevel = w.getPatientPermissionLevel() == b.PatientPermissionLevel.All || w.getPatientPermissionLevel() == b.PatientPermissionLevel.Department;
                n.commands = et;
                n.onCommandClick = st;
                n.exportExcel = ht;
                n.refreshGrid = u;
                pt();
                ut();
                lt();
                t(function() { ct() }) })() } } }]);
dashboardModule.directive("officeResourceView", ["$log", "$timeout", "$window", "dataDicSvc", "enums", function(n, t, i, r, u) { "use strict"; return { restrict: "E", replace: !0, templateUrl: "/app/dashboard/views/office-resource/office-resource-view.html", link: function(n, f) { var h = function() { n.searchListContainer && n.searchListContainer.data("mCustomScrollbarIndex") ? n.searchListContainer.mCustomScrollbar("update") : t(function() { n.searchListContainer = f.find(".search-list"); var r = angular.element(i).height() - 130;
                        n.searchListContainer.mCustomScrollbar({ scrollButtons: { enable: !1 }, autoHideScrollbar: !0, scrollInertia: 300, advanced: { updateOnContentResize: !0, autoScrollOnFocus: !1 }, mouseWheel: { preventDefault: !0 }, callbacks: { whileScrolling: function(i) { var r, u;
                                    i.topPct >= 90 && n.pageIndex + 1 <= n.totalPage && n.isNextPage && (n.pageIndex++, n.isNextPage = !1, n.dividePageDataArr[n.pageIndex] && n.dividePageDataArr[n.pageIndex].length > 0 && (r = n.currentResource.length, u = angular.copy(n.dividePageDataArr[n.pageIndex]), t(function() { n.currentResource = n.currentResource.concat(u);
                                        r !== n.currentResource.length && (n.isNextPage = !0) }))) } } });
                        n.searchListContainer.height(r) }) },
                o, c = function() { f.find("#department").kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", optionLabel: "全部科室", change: function() { n.filterCondition = this.value();
                            t(function() { n.pageIndex = 0;
                                n.initProvider(n.isActive) }) } });
                    r.departmentDic.load().then(function(n) { var t = n;
                        o = f.find("#department").data("kendoDropDownList");
                        o.setDataSource(t);
                        o.trigger("change") }) },
                e, l = function(i) { var u = f.find("#sortCondition"),
                        r;
                    u.kendoDropDownList({ dataTextField: "itemName", dataValueField: "itemName", change: function() { n.selectCondition = this.value();
                            t(function() { n.pageIndex = 0;
                                n.initProvider(n.isActive) }) } });
                    e = u.data("kendoDropDownList"); switch (i) {
                        case 0:
                            r = [{ itemName: "拼音排序" }, { itemName: "状态排序" }];
                            e.setDataSource(r); break;
                        case 1:
                            r = [{ itemName: "拼音排序" }, { itemName: "状态排序" }];
                            e.setDataSource(r); break;
                        case 2:
                            r = [{ itemName: "编号排序" }, { itemName: "状态排序" }];
                            e.setDataSource(r) } },
                s = function(i) { n.pageIndex = 0;
                    n.isActive = i;
                    n.isNextPage = !0;
                    n.initProvider(i);
                    t(function() { n.isActive !== 2 && c();
                        l(i) }) },
                a = function() { s(0) },
                v = function(n) { n.isShowBtn = !n.isShowBtn },
                y = function(n) { n.isShowMorePatient = !n.isShowMorePatient },
                p = function(t) { var i;
                    t.isNotUse = !t.isNotUse;
                    t.isShowBtn = !t.isShowBtn;
                    i = n.isActive !== 2 ? u.ResourceType.Provider : u.ResourceType.Operatory;
                    t.sortState = t.isNotUse ? 2 : t.hasInProgressPatient.length > 0 ? 1 : 0;
                    n.toggleResourceBlockState(i, t.id) };
            (function() { n.isActive = 0;
                n.toggleTab = s;
                n.showToggleBtn = v;
                n.toggleUse = p;
                n.showPatientInfo = y;
                n.initScrollbar = h;
                a() })() } } }]);
dashboardModule.controller("OfficeResourceCtrl", ["$log", "$scope", "$modalInstance", "$filter", "$timeout", "loginContext", "appointmentSvc", "dataDicSvc", "enums", "apptUtil", function(n, t, i, r, u, f, e, o, s, h) { "use strict"; var v = function() { i.dismiss() },
        y = function(n) { switch (n) {
                case 0:
                    o.consultantDic.loadActive().then(function(n) { var t = s.ResourceType.Provider;
                        c(t, n) }); break;
                case 1:
                    o.doctorDic.loadActive().then(function(n) { n = _.filter(n, function(n) { return n.show == !0 }); var t = s.ResourceType.Provider;
                        c(t, n) }); break;
                case 2:
                    o.operatoryDic.loadActive().then(function(n) { var t = s.ResourceType.Operatory;
                        c(t, n) }) } },
        c = function(n, t) { var i = p(t);
            w(n, i[0], i[1]) },
        p = function(n) { var t = [],
                i = []; return _.each(n, function(n) { i.push(n.id);
                t.push(n) }), [t, i] },
        l = function(n) { var i = {},
                r = 0,
                u = 1; return i[r] = [], _.each(n, function(n) { i[r].push(n);
                i[r].length >= t.pageSize && (r++, i[r] = [], u++) }), i },
        w = function(n, t, i) { e.searchResourceBlock(n, i).success(function(i) { i && i.length > 0 && _.each(t, function(t) { var r = _.find(i, function(i) { return t.id === i.resourceId && n === i.resourceType });
                    r ? (t.isNotUse = !0, t.sortState = 2) : t.isNotUse = !1 });
                k(t) }) },
        b = function(n, t) { e.toggleResourceBlockState(n, t).success(function() {}) },
        k = function(n) { var i = moment(Ares.today()).format("YYYY-MM-DD"),
                r = moment(Ares.tomorrow()).format("YYYY-MM-DD"),
                u = { officeId: t.officeId || f.officeId, startTime: i, endTime: r, isCancelled: !1, isApptTimeRequired: !0, isPrivateIdRequired: !0 };
            e.searchFullAppointments(u).success(function(i) { var r = { consultantId: {}, doctorId: {}, operatoryId: {} },
                    u;
                _.each(i, function(n) { g(n);
                    t.isActive === 0 ? (r.consultantId[n.consultantId] = r.consultantId[n.consultantId] || [], r.consultantId[n.consultantId].push(n.patient)) : t.isActive === 1 ? (r.doctorId[n.doctorId] = r.doctorId[n.doctorId] || [], r.doctorId[n.doctorId].push(n.patient)) : (r.operatoryId[n.operatoryId] = r.operatoryId[n.operatoryId] || [], r.operatoryId[n.operatoryId].push(n.patient)) });
                u = d(n, r);
                tt(u) }) },
        d = function(n, i) { return _.each(n, function(n) { t.isActive === 0 ? i.consultantId[n.id] && (n.patients = i.consultantId[n.id]) : t.isActive === 1 ? i.doctorId[n.id] && (n.patients = i.doctorId[n.id]) : i.operatoryId[n.id] && (n.patients = i.operatoryId[n.id]) }), t.isActive !== 2 ? _.sortBy(n, "nameCode") : _.sortBy(n, "showOrder") },
        g = function(n) { var i = moment(new Date),
                t = moment(n.endTime),
                r;
            moment(t, "hh:mm").isBefore(moment(i, "hh:mm")) ? (n.patient.overTime = !0, r = moment(i, "hh:mm").diff(moment(t, "hh:mm"), "m"), n.patient.overTimeCount = nt(r)) : (n.patient.overTime = !1, n.patient.startTime = moment(n.startTime).format("HH:mm"), n.patient.endTime = moment(t).format("HH:mm"));
            n.patient.isCheckedIn = h.compareApptState(n, "=isCheckedIn");
            n.patient.isConsulting = h.compareApptState(n, "=isConsulting");
            n.patient.isConsultCompleted = h.compareApptState(n, ">isConsulting");
            n.patient.isSeated = h.compareApptState(n, "=isSeated");
            n.patient.isCompleted = h.compareApptState(n, ">=isCompleted");
            n.patient.doctorName = n.doctorName;
            n.transactionCodeStr && (n.patient.transactionCodeStr = n.transactionCodeStr) },
        nt = function(n) { return n < 60 ? Math.floor(n / 15) * 15 + "分钟" : Math.floor(n / 60) + "小时" },
        tt = function(n) { var i, u;
            _.each(n, function(n) { t.isActive === 0 && (n.waitingPatient = _.filter(n.patients, function(n) { return n.isCheckedIn === !0 }), n.hasInProgressPatient = _.filter(n.patients, function(n) { if (n.isConsulting) return n.imgSrc = r("patientPhoto")(null, n), n }), n.hasCompletedPatient = _.filter(n.patients, function(n) { return n.isConsultCompleted === !0 }), n.hasCompletedPatientCount = n.hasCompletedPatient.length);
                t.isActive === 1 && (n.waitingPatient = _.filter(n.patients, function(n) { if (n.isCheckedIn || n.isConsulting) return n }), n.hasInProgressPatient = _.filter(n.patients, function(n) { if (n.isSeated) return n.imgSrc = r("patientPhoto")(null, n), n }), n.hasCompletedPatient = _.filter(n.patients, function(n) { return n.isCompleted === !0 }), n.hasCompletedPatientCount = n.hasCompletedPatient.length);
                t.isActive === 2 && (n.hasInProgressPatient = _.filter(n.patients, function(n) { if (n.isSeated) return n.imgSrc = r("patientPhoto")(null, n), n }), n.randomDoctor = _.find(n.hasInProgressPatient, function(n) { if (n.doctorName) return n }), n.randomDoctor && (n.randomDoctorName = n.randomDoctor.doctorName));
                n.sortState !== 2 && (n.hasInProgressPatient.length == 0 && (n.sortState = 0), n.hasInProgressPatient.length > 0 && (n.sortState = 1)) });
            i = angular.copy(n);
            t.unDivideAllData = t.filterCondition ? _.filter(i, function(n) { if (n.department === t.filterCondition) return n }) : i;
            t.unDivideAllData = t.selectCondition === "状态排序" ? _.sortBy(t.unDivideAllData, "sortState") : t.isActive !== 2 ? _.sortBy(t.unDivideAllData, "showOrder") : _.sortBy(t.unDivideAllData, "nameCode");
            t.dividePageDataArr = l(t.unDivideAllData);
            u = t.unDivideAllData.length;
            t.totalPage = u > t.pageSize ? Math.ceil(u / t.pageSize) : 1;
            a() },
        a = function() { t.dividePageDataArr[t.pageIndex].length >= 0 && (t.isNextPage = !0, t.currentResource = angular.copy(t.dividePageDataArr[t.pageIndex]));
            u(function() { t.initScrollbar();
                t.searchListContainer && t.searchListContainer.data("mCustomScrollbarIndex") && t.searchListContainer.mCustomScrollbar("scrollTo", "top") }, 500) };
    (function() { t.closeSlideModal = v;
        t.toggleResourceBlockState = b;
        t.initProvider = y;
        t.getFirstPage = a;
        t.dividePageOption = l;
        t.pageSize = 10 })() }]);